android-contentprovider

Closing the SQLiteDatabase in a Content Provider

╄→尐↘猪︶ㄣ 提交于 2019-12-10 20:19:10
问题 I'm looking through the NotePad example that comes with the Android SDK and I was wondering if someone could clarify why the the variable db is never closed in the update function? It's usually a good idea to close the database when it is no longer in use to prevent leaks. Ideas? @Override public int update(Uri uri, ContentValues values, String where, String[] whereArgs) { // Opens the database object in "write" mode. SQLiteDatabase db = mOpenHelper.getWritableDatabase(); ... // More code, db

getting changed uri on ContentObserver Onchange on older versions of the API [duplicate]

旧城冷巷雨未停 提交于 2019-12-10 20:13:46
问题 This question already has answers here : Closed 6 years ago . Possible Duplicate: How to get URI of inserted row in my content observer? I am using ContentObserver to listen to changes on a content provider. However, I was wondering if there is a way to get the changed URI when the OnChange method is called (instead of doing a search query inside the callback in order to find out what has changed). It seem that this is possible with the API level 16, but I have to write an API 8 compliant

Is there any phone that doesn't have sms inbox content provider?

ぐ巨炮叔叔 提交于 2019-12-10 18:49:05
问题 Is there any phone that doesn't have typical sms content provider ("content://sms/inbox")? Or there is any phone that has different fields scheme? 回答1: Well, there are tablets that don't have telephony services so I guess it's possible that it doesn't work or just doesn't contain anything :-) 回答2: Android is open-source, so, technically, a company doing a custom ROM could desactivate this kind of functionnality, but I think that if the phone is able to send/receive SMS, the content provider

Syncing contacts using SyncAdapter ,Working

我与影子孤独终老i 提交于 2019-12-10 18:10:37
问题 I am currently working on a android project in which I want to Sync mobile contacts to server, After researching a lot about SyncAdapter and Creating account in accountmanager , I have learned it myself. however there are two things I don't understand, I searched about these in google but could not get perfect answer. Please don't duplicate the question, I want to know more clearly how it works. As the Google documentation says whenever a sync is done, the dirty flag of the contact gets

Error in insert data in Own Content Provider?

心不动则不痛 提交于 2019-12-10 17:38:05
问题 Here i make my own home screen launcher when i make vent of longpress on screen than i got one dialog box of select options like Widget and Shortcuts etc. so when i select Widget than i got another dialog box like inbuilt applications widgets. when i select any widget for load than i have problem I implemented this whole code with reference of Android 2.3 Source code. here in this code i have own content provider. When i access its override method insert from another Class using

Share Assets Using fileprovider

六月ゝ 毕业季﹏ 提交于 2019-12-10 16:33:38
问题 Followed https://developer.android.com/training/secure-file-sharing/index.html and able to share files in the internal directory(/data/data/package/files/xxx/) of app to client app using fileprovider. How to share the files in assets folder(instead of internal directory) to the client app. Thanks 回答1: See CWAC-Provider from CommonsWare which is a library to do precisely what you want. 回答2: This is the way i used finally, hope this will help someone. Added provider in manifest file <provider

How to share files from any path using a FileProvider?

那年仲夏 提交于 2019-12-10 16:03:52
问题 My app allows the user to download some content and store it in the folder of his choice. I want to create a ContentProvider to share those files, but I don't know how to do that when the downloaded files are stored outside of the app default path. I tried to decalre to following filePath: <paths xmlns:android="http://schemas.android.com/apk/res/android"> <files-path name="." path="/" /> </paths> but it just try to match shared file path with the root of the app default folder. Is there a way

How and when to use a ContentProviderClient obtained using acquireUnstableContentProviderClient?

旧巷老猫 提交于 2019-12-10 15:57:28
问题 How is using a ContentProviderClient obtained with ContentResolver#acquireContentProviderClient(...) any different from ContentResolver#acquireUnstableContentProviderClient(...) ? It seems like I would write the same code regardless of which method I used. Is there going to be some kind of leak in my app if the ContentProvider acquired goes away and I used the non-unstable method to acquire the client? So I guess that if the ContentProvider you want to use is running in the same process or if

IllegalStateException “attempt to re-open an already-closed object” in SimpleCursorAdapter from ContentProvider

谁说胖子不能爱 提交于 2019-12-10 15:14:01
问题 I have a series of ListView objects in Fragment s that are being populated by a CursorAdapter which gets a Cursor from the LoaderManager for the activity. As I understand it, all database and Cursor close actions are completely handled by the LoaderManager and the ContentProvider , so at no point in any of the code am I calling .close() on anything. Sometimes, however, I get this exception: 02-19 11:07:12.308 E/AndroidRuntime(18777): java.lang.IllegalStateException: attempt to re-open an

Android WebView not allowed to load local video file

扶醉桌前 提交于 2019-12-10 15:05:11
问题 I have an application with a WebView showing an HTML file. In the HTML file, there's a button that will request the user to record video, or select a video from his documents folder. Upon selecting (or recording) a video, it calls a javascript function with the link (encoded by Uri) to the video file, which it should then display in a element, by setting it as its source: function showPreview(previewFile){ console.log(previewFile); document.getElementById('previewVideo').src = previewFile; }