mediastore

Set raw resource as ringtone in Android

╄→尐↘猪︶ㄣ 提交于 2019-11-29 22:46:08
问题 In my android application, I want to set audio file from my raw folder as a ringtone. For that i wrote below code, but its not working. Please help me to solve this issue. Thank you. Code : String name =best_song_ever.mp3; File newSoundFile = new File("/sdcard/media/ringtone", "myringtone.mp3"); Uri mUri = Uri.parse("android.resource://" + context.getPackageName() + "/raw/" + name); ContentResolver mCr = context.getContentResolver(); AssetFileDescriptor soundFile; try { soundFile = mCr

How to Save images to ImageView using Shared Preferences

陌路散爱 提交于 2019-11-29 17:57:15
I have an activity that opens another activity to get a download pic. The picture comes back to my original activity and rest in an imageView. That's working fine. How do I save the image so when the user comes back later, or kills to app the image is still there. I know I am supposed the use Shared Preferences to get the image path and not save the image itself but I just don't know how do that. Main Activity public class MainActivity extends Activity { private static final int REQUEST_CODE = 1; private Bitmap bitmap; Button button; ImageView imageView; String selectedImagePath; @Override

How to query for songs in playlists on Android SDK?

梦想的初衷 提交于 2019-11-29 14:26:08
问题 So my question is how to query for playlist content. I can make a query to display all the playlists, but how to make a query to display songs in a specific playlist. Thanks 回答1: Okay, so I have manged to put the code together myself. So this is it : String[] proj = { MediaStore.Audio.Playlists.Members.AUDIO_ID, MediaStore.Audio.Playlists.Members.ARTIST, MediaStore.Audio.Playlists.Members.TITLE, MediaStore.Audio.Playlists.Members._ID }; c = getContentResolver().query( MediaStore.Audio

Get MediaStore path of a Specific Folder

假如想象 提交于 2019-11-29 14:18:28
I'm creating an update for my application, in it I have a folder with saved images that I would like to display in a GridView. I am already using the Ion library . The creator of the library (Koush Dutta) already has a sample doing what I want and displays all of the images from the SD Card in a GridView. . What I want to do is display only the images from a specific folder on my SD Card (called comics) in the GridView. I am using the code directly from the sample above, only modifying some names. My Problem is that I cannot get only the images from the SD Card into the GridView, currently it

Android Can I use JOIN at mediastore query

浪子不回头ぞ 提交于 2019-11-29 12:11:22
is there any method to use join in a query at mediastore data? Or also is there any method to access the mediastore data through a database and not with the content provider? Thank you. But I think that you can use joins with content providers. If you make two queries, you can join them by using CursorJoiner. I am using it and it works good. Snippet from Android docs: CursorJoiner joiner = new CursorJoiner(cursorA, keyColumnsofA, cursorB, keyColumnsofB); for (CursorJointer.Result joinerResult : joiner) { switch (joinerResult) { case LEFT: // handle case where a row in cursorA is unique break;

Android - MediaStore.Video.query() is returning null

只谈情不闲聊 提交于 2019-11-29 07:14:52
I'm trying to retrieve the metadata from a video file (title, language, artist) using the method MediaStore.Video.query(). However, the method is always returning null. The code is bellow: String[] columns = { MediaStore.Video.VideoColumns._ID, MediaStore.Video.VideoColumns.TITLE, MediaStore.Video.VideoColumns.ARTIST }; Cursor cursor = MediaStore.Video.query(getApplicationContext().getContentResolver(), videoUri,columns); if (cursor != null) { cursor.moveToNext(); } String title = cursor.getString(cursor.getColumnIndex(MediaStore.Video.VideoColumns.TITLE)); Any suggestion about how to return

How can I display a specific folder in Android Gallery3D (cooliris)?

╄→гoц情女王★ 提交于 2019-11-29 02:37:23
I'm using Gallery3D (froyo-stable) I'm trying to make a little app that displays only images from a specific folder in a gallery view. Uri targetUri = Media.EXTERNAL_CONTENT_URI; String folderPath = Environment.getExternalStorageDirectory().toString() + "/DCIM/"; int folderBucketId = folderPath.toLowerCase().hashCode(); targetUri = targetUri.buildUpon().appendQueryParameter("bucketId", String.valueOf(folderBucketId)).build(); In initializeDataSource() // Creating the DataSource objects. final LocalDataSource localDataSource = new LocalDataSource(Gallery.this, targetUri.toString(), false); But

MediaStore.Images.Media.insertImage is returning null when trying to save the image

喜夏-厌秋 提交于 2019-11-28 20:29:48
I am using an custom view and in that i am using an canvas in which a user can draw anything and after that i want to save that image in sd card bt was not able to do that. Don't know what is going on. else if(view.getId()==R.id.save_btn){ //save drawing AlertDialog.Builder saveDialog = new AlertDialog.Builder(this); saveDialog.setTitle("Save drawing"); saveDialog.setMessage("Save drawing to device Gallery?"); saveDialog.setPositiveButton("Yes", new DialogInterface.OnClickListener(){ private FileOutputStream fOut; public void onClick(DialogInterface dialog, int which){ //save drawing drawView

Tell the Camera Intent to save the taken image

不问归期 提交于 2019-11-28 14:06:41
I'm doing this: intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); final File storage = Environment.getExternalStorageDirectory(); final Uri uri = Uri.fromFile(new File(storage, System.currentTimeMillis() + ".jpg")); intent.putExtra(MediaStore.EXTRA_OUTPUT, uri); startActivityForResult(intent, id); and to handle get that photo, I do this: private String getLastImagePath() { final String[] imageColumns = { MediaStore.Images.Media._ID, MediaStore.Images.Media.DATA }; final String imageOrderBy = MediaStore.Images.Media._ID + " DESC"; final Cursor imageCursor = getContentResolver().query(

Empty cursor from the MediaStore

我们两清 提交于 2019-11-28 10:31:33
I can't figure out why this cursor is empty in just this one particular device. but works on all other android devices. There are several audiofiles on the sdcard, and the stock mediaplayer can find and play these songs alright. Cursor c = managedQuery(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, new String[] { "distinct " + MediaStore.Audio.Media.ALBUM, MediaStore.Audio.Media.ARTIST, MediaStore.Audio.Media.ALBUM_KEY, MediaStore.Audio.Media.ALBUM_ID}, null, null, MediaStore.Audio.Media.ARTIST); Both the ambling book player (I'm guessing they just loop through the folders and do their own id3