android-contentresolver

Downloaded SQLite database and leak warnings

独自空忆成欢 提交于 2019-12-11 04:15:12
问题 I've made an application that uses a downloaded SQLite database. To retrieve data in it I'm using a ContentProvider . When I need to read the database, I always (I've checked at least five times) use a code like this: Cursor c = getContext().getContentResolver().query(MyContentProvider.ITEMSURI, projection,where,null,null); if(c.moveToFirst()){ while(!c.isAfterLast()){ itemsList.add(cursorToItem(c)); c.moveToNext(); } } if(c!=null) c.close(); But I keep getting many errors like this (I make a

Android CalendarContract, deleting a recurring event causes all events to disappear on calendar?

守給你的承諾、 提交于 2019-12-11 02:46:09
问题 I have a sync adapter that handles syncing calendars and events. I am able to delete normal events just fine. But whenever I delete a recurring event, all the events on my calendar disappear. One thing I noticed is that whenever I deleted a recurring event, the Instances table is emptied, which explains the events disappearing. The Events table is as expected, with the recurring event row deleted from the table. What is causing this? I have tried deleting in the following ways: resolver

my Android ContentProvider can't find ContentResolver

有些话、适合烂在心里 提交于 2019-12-11 02:09:10
问题 My goal is writing a ContentProvider without an Activity. For testing I wrote a test - activity in a own app. For those who want to tell me that there is still a logger included in android, I know this. Here is part of the ContentProvider public static final String AUTHORITY = "de.xyz.android.log4android"; public static final int LOGGER_ARROW_URI_ID = 1; public static final String ARROW_CONTENT_TYPE = "vnd.de.xyz.android.cursor.dir/vnr.log"; public static final int LOGGER_ITEM_URI_ID = 2;

ContentResolver.insert returns null

≡放荡痞女 提交于 2019-12-10 18:02:22
问题 I sometimes have a problem when setting sounds as ringtones / notifications from inside an activity: ContentValues values = new ContentValues(); values.put(MediaStore.MediaColumns.DATA, source); values.put(MediaStore.MediaColumns.TITLE, "abc"); values.put(MediaStore.MediaColumns.SIZE, new File(source).length()); values.put(MediaStore.MediaColumns.MIME_TYPE, mime); values.put(MediaStore.Audio.Media.ARTIST, "xyz"); values.put(MediaStore.Audio.Media.IS_RINGTONE, true); values.put(MediaStore

Getting file from content uri for videos taken

余生长醉 提交于 2019-12-10 17:39:56
问题 I have a method below: private String getRealPathFromUriForVideos(Uri selectedVideoUri) { String wholeID = DocumentsContract.getDocumentId(selectedVideoUri); String id = wholeID.split(":")[1]; String[] column = { MediaStore.Video.Media.DATA }; String sel = MediaStore.Video.Media._ID + "=?"; Cursor cursor = getContentResolver().query(MediaStore.Video.Media.EXTERNAL_CONTENT_URI, column, sel, new String[]{ id }, null); String filePath = ""; int columnIndex = cursor.getColumnIndex(column[0]); if

How to update a native contact photo on android?

Deadly 提交于 2019-12-10 17:11:01
问题 I am working on one sample application just to insert, update and delete the native android contact. I am able to successfully insert, update and delete the contact. But the problem in updating the contact photo. Below images are the observation where the same contact having two different issue. After updating the contact, first image is still displaying the old image. But where as when i view the full details i am able to view the newly updated contact image as shown in the second image.

Content resolver returns wrong size

拈花ヽ惹草 提交于 2019-12-10 13:53:52
问题 I am picking an image from the gallery and querying its size via ContentResolver API, it returns 29kb. However when I check the file via adb using ls -al it is 44kb here is how I query the size of the image: private fun getFileInfo(contentResolver: ContentResolver, fileUri: Uri): Pair<String, Long>? { val projection = arrayOf(MediaStore.MediaColumns.DISPLAY_NAME, MediaStore.MediaColumns.SIZE) val metaCursor = contentResolver.query(fileUri, projection, null, null, null) metaCursor?.use { if

getcontentresolver () is undefined for the type

偶尔善良 提交于 2019-12-09 17:53:52
问题 I try to get all contact names and number and i'm trying to use getContentResolver but i am getting the method get content resolver () is undefined for the type this error. How can i fix it ? Here is the code below : public class ContactManager { public ArrayList<Product> getContactNumber() { Cursor phones = getContentResolver().query( ContactsContract.CommonDataKinds.Phone.CONTENT_URI, null, null, null, null); while (phones.moveToNext()) { String name = phones .getString(phones

How do I restrict access to my ContentProvider to only my apps?

给你一囗甜甜゛ 提交于 2019-12-09 07:33:17
问题 I want to export a ContentProvider for use by another one of MY apps. How do I prevent other apps from accessing it? If I use an android:permission attribute, can't 3rd party apps just apply that permission to their app? I really need to lock down access to my apps only. Thanks in advance... 回答1: If I use an android:permission attribute, can't 3rd party apps just apply that permission to their app? Well, you can use a signature -level custom permission ( android:protectionLevel="signature" ).

How to implement read-only ContentProvider?

こ雲淡風輕ζ 提交于 2019-12-08 21:15:13
问题 I am wondering how to best implement a read-only ContentProvider. I want my data source to be modified only from within my own application through additional special methods of my ContentProvider (which of course are not accessible through a ContentResolver). In other words, other applications should only be able to use my ContentProvider's query method but not insert, delete, or update. The obvious solution seems to be to just return null/0/0 and do nothing else in insert/delete/update.