android-contentprovider

MediaStore: get image data, thumbnail and folder

☆樱花仙子☆ 提交于 2019-11-30 05:03:01
问题 I have two lists. Let's call them AlbumsList and PicturesList. The first one shows photo album cover (one of the images from it) it's name and number of pictures in it. The second one shows all of the images contained in a chosen album. I've already done it using File class but it works too slow and finds all of the images on device when I need only those from gallery. I've read about MediaStore content provider but have never used it. So I have 2 questions: How to find "photo albums"

Android duplicate provider authority problem

£可爱£侵袭症+ 提交于 2019-11-30 04:36:37
问题 We're trying to publish a pay ad-free version of a casual app that's currently published free with ads. We refactored all package names to com.mycompanyname.appname.pro , the free one on market doesn't have the .pro at the end, basically. We also went into our content provider and changed the authority to the same as the package name. So the "free version" has AUTHORITY = "com.mycompanyname.appname" and the "ad-free pay version has AUTHORITY = "com.mycompanyname.appname.pro" but still we are

Android - get email attachment name in my application

拟墨画扇 提交于 2019-11-30 04:05:18
问题 I'm trying to load an email attachment in my application. I can get the content, but I cannot get the file name. Here's how my intent filter looks like: <intent-filter> <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.DEFAULT" /> <data android:mimeType="image/jpeg" /> </intent-filter> Here is what I get: INFO/ActivityManager(97): Starting: Intent { act=android.intent.action.VIEW dat=content://gmail-ls/messages/john.doe%40gmail.com/42

Batch Delete items with Content Provider in Android

Deadly 提交于 2019-11-30 03:38:19
问题 I'm trying to batch delete some items in a table. String ids = { "1", "2", "3" }; mContentResolver.delete(uri, MyTables._ID + "=?", ids); However I keep getting this following error java.lang.IllegalArgumentException: Too many bind arguments. 3 arguments were provided but the statement needs 1 arguments. 回答1: The error occurs because you have a single placeholder (?) in your where clause, while you pass three arguments. You should do: String ids = { "1", "2", "3" }; mContentResolver.delete

Failed to find provider info for 'ContentProvider'

妖精的绣舞 提交于 2019-11-30 02:54:17
I have a problem that I just cannot figure out. I am using Eclipse to create my own Content Provider but keep getting the following error: [..] ERROR/ActivityThread(1051): Failed to find provider info for my.package.provider.countrycontentprovider Code found here: http://codepad.org/Rx00HjHd Main parts: public class CountryContentProvider extends ContentProvider { public static final String PROVIDER = "my.package.provider.countrycontentprovider"; public static final Uri CONTENT_URI = Uri.parse("content://" + PROVIDER + "/country"); // ... @Override public boolean onCreate() { return true; } //

How to create a Thread-safe ContentProvider?

百般思念 提交于 2019-11-30 02:07:56
Android documentation says ContentProvider methods can be called from various ContentResolver objects in different processes and threads, they must be implemented in a thread-safe manner And I found this post on Stackoverflow Android - sqlite content providers and multithreading which says it's thread safe already ?? So, Just wondering how to create a thread-safe ContentProvider ? Is it enough if I make the insert/update/delete methods syncronized public synchronized Uri insert (Uri uri, ContentValues values) { } You could make every method synchronized , but make sure it is absolutely

What to do when - java.io.FileNotFoundException: No content provider?

烂漫一生 提交于 2019-11-30 01:16:54
when I try to attach a file to an email, I get a java.io.FileNotFoundException: No content provider logcat output. If anyone could tell me what I am doing wrong or what I should do instead, that would be great.Thank you. This is how I add the files to the email..: Intent sendIntent = new Intent(Intent.ACTION_SEND); sendIntent.putExtra(Intent.EXTRA_STREAM, uri); sendIntent.setType("video/3gp"); sendIntent.setType("video/mp4"); startActivity(sendIntent); ...and here is the entire logcat error output: 07-20 09:15:58.364: ERROR/Mms/media(168): IOException caught while opening or reading stream 07

Master-detail Using ContentResolver.applyBatch()?

南笙酒味 提交于 2019-11-30 00:11:43
I was wondering if its possible to save master and detail records to a content provider using the android.content.ContentResolver.applyBatch() method in the same operation where subsequent ContentProviderOperation items in the providers parameter depend on the result of previous items. The problem I'm having is that the actual Uri isn't known at the time that the ContentProviderOperation.newInsert(Uri) method is called and the Uri is immutable. What I have come up with is shown below: Master Uri: content://com.foobar.masterdetail/master Detail Uri: content://com.foobar.masterdetail/master/#

ContentResolver doesn't contain just created image in an immediate query after creation of file

删除回忆录丶 提交于 2019-11-29 23:54:40
问题 I'm using this code to copy an image using documentFile.createFile() private void newcopyFile(File fileInput, String outputParentPath, String mimeType, String newFileName) { DocumentFile documentFileGoal = DocumentFile.fromTreeUri(this, treeUri); String[] parts = outputParentPath.split("\\/"); for (int i = 3; i < parts.length; i++) { if (documentFileGoal != null) { documentFileGoal = documentFileGoal.findFile(parts[i]); } } if (documentFileGoal == null) { Toast.makeText(MainActivity.this,

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