导入图片到图片加 以及 搜索音乐

1.

String filename = String.valueOf(System.currentTimeMillis()) ;

ContentValues values = new ContentValues();
values.put(Images.Media.TITLE, filename);
values.put(Images.Media.DATE_ADDED, System.currentTimeMillis());
values.put(Images.Media.MIME_TYPE, "image/jpeg");

Uri uri = context.getContentResolver().insert(Images.Media.EXTERNAL_CONTENT_URI, values);
try {
OutputStream outStream = context.getContentResolver().openOutputStream(uri);
mBitmap.compress(Bitmap.CompressFormat.JPEG, 90, outStream);
outStream.flush();
outStream.close();
Log.d("done","done");
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
2.

public class Main extends ListActivity {
  private Cursor audioCursor;

  /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    audioCursor = this.managedQuery(Audio.Media.EXTERNAL_CONTENT_URI,
        null, null, null, null);
    startManagingCursor(audioCursor);

    String[] columnsToMap = new String[] {Audio.Media.TITLE ,
                                          Audio.Media._ID};
    int[] mapTo = new int[] {android.R.id.text1,android.R.id.text2};

    ListAdapter mAdapter = new SimpleCursorAdapter(this,
        android.R.layout.two_line_list_item ,
        audioCursor, columnsToMap, mapTo);
    this.setListAdapter(mAdapter);
  }
}

你可能感兴趣的:(android,音乐)