android-contentresolver

How does getContentResolver() work?

依然范特西╮ 提交于 2019-12-02 17:12:17
I watched a course about ContentProvider on the Internet demonstrating how to define and use a ContentProvider . I was confused about using the method named getContentResolver() . What does this method return? My ContentProvider is not instanced and the code just writes that getContentProvider().query() . I don't understand how ContentProvider works. Aditya It returns Content Resolver. What is the Content Resolver? The Content Resolver is the single, global instance in your application that provides access to your (and other applications') content providers. The Content Resolver behaves

Android Contacts provider get only phone contacts with all emails

南笙酒味 提交于 2019-12-02 16:43:32
I need to get all phone contacts and their email address and photo uri: This is what am doing: private void getContacts() { ContentResolver cr = getContentResolver(); Cursor cur = cr.query(Contacts.CONTENT_URI, null, null, null, Contacts.DISPLAY_NAME); if (cur.getCount() > 0) { while (cur.moveToNext()) { // if // (Integer.parseInt(cur.getString(cur.getColumnIndex(ContactsContract.Contacts.HAS_PHONE_NUMBER))) // > 0) { Contact contact = new Contact(); String id = cur.getString(cur.getColumnIndex(ContactsContract.Contacts._ID)); Uri uri = getContactPhotoUri(Long.parseLong(id)); // set photoUri

How to select multiple contacts at a time?

只愿长相守 提交于 2019-12-01 21:44:54
I retrieve phonebook contacts to my application by using following code: public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); Intent contactPickerIntent = new Intent(Intent.ACTION_PICK, Contacts.CONTENT_URI); startActivityForResult(contactPickerIntent, CONTACT_PICKER_RESULT); } But I want to select multiple contacts and upload those to a DB. Is this possible and if so how can I do this? senola Well you could query the content provider directly inside your activity so the user can select multiple contact. This can be achieved using

How does Content Provider's application specify permissions that client apps need in order to access the provider's data?

那年仲夏 提交于 2019-12-01 14:35:50
问题 BACKGROUND I am reading this tutorial on Android Content Providers. I understand from this tutorial that, In order for other applications to access a Content Provider's data, the provider application must specify the permissions which the client applications need to have to access the its provider's data. Client applications specify the permissions they require in their manifest file using the <uses-permission> element, e.g. <uses-permission android:name="android.permission.READ_USER

Disable window and transition settings

坚强是说给别人听的谎言 提交于 2019-12-01 11:48:53
So what I need to do is toggle window and/or transition animations on and off in code, to have the same effect of going Settings > Display > Animations > Disable all animations. The way I am familiar with changing device settings is by using a ContentResolver within the Settings.System.putInt() method as follows: ContentResolver cr = getContentResolver(); Settings.System.putInt(cr, Settings.System.WINDOW_ANIMATION_SCALE, 0); As described in the documentation 'Setting to 0 will disable all .... animations' for both settings. When reading the setting before and after using the putInt() method,

In Android 7, ContentResolver's method-openAssetFileDescriptor(vCardUri, “r”) returns AssetFileDescriptor having declaredLength as -1

雨燕双飞 提交于 2019-12-01 11:04:55
In Android 7, getContentResolver().openAssetFileDescriptor(vCardUri, "r") returns AssetFileDescriptor having declaredLength as -1 returned by getDeclaredLength() . Trying to export the contacts as vcards into vcf file. The code I have tried is as follows Uri uri = Uri.withAppendedPath(ContactsContract.Contacts.CONTENT_VCARD_URI, lookupKey); AssetFileDescriptor fd = resolver.openAssetFileDescriptor(uri, "r"); FileInputStream fis = fd.createInputStream(); byte[] b = new byte[(int)fd.getDeclaredLength()]; fis.read(b); The above code works perfectly in Android 6 or below.But when ran using Android

Disable window and transition settings

梦想与她 提交于 2019-12-01 10:53:50
问题 So what I need to do is toggle window and/or transition animations on and off in code, to have the same effect of going Settings > Display > Animations > Disable all animations. The way I am familiar with changing device settings is by using a ContentResolver within the Settings.System.putInt() method as follows: ContentResolver cr = getContentResolver(); Settings.System.putInt(cr, Settings.System.WINDOW_ANIMATION_SCALE, 0); As described in the documentation 'Setting to 0 will disable all ...

In Android 7, ContentResolver's method-openAssetFileDescriptor(vCardUri, “r”) returns AssetFileDescriptor having declaredLength as -1

我怕爱的太早我们不能终老 提交于 2019-12-01 09:40:01
问题 In Android 7, getContentResolver().openAssetFileDescriptor(vCardUri, "r") returns AssetFileDescriptor having declaredLength as -1 returned by getDeclaredLength() . Trying to export the contacts as vcards into vcf file. The code I have tried is as follows Uri uri = Uri.withAppendedPath(ContactsContract.Contacts.CONTENT_VCARD_URI, lookupKey); AssetFileDescriptor fd = resolver.openAssetFileDescriptor(uri, "r"); FileInputStream fis = fd.createInputStream(); byte[] b = new byte[(int)fd

Using mp4parser , how can I handle videos that are taken from Uri and ContentResolver?

荒凉一梦 提交于 2019-12-01 02:32:41
Background We want to let the user choose a video from any app, and then trim a video to be of max of 5 seconds. The problem For getting a Uri to be selected, we got it working fine (solution available here ) . As for the trimming itself, we couldn't find any good library that has permissive license, except for one called "k4l-video-trimmer" . The library "FFmpeg", for example, is considered not permission as it uses GPLv3, which requires the app that uses it to also be open sourced. Besides, as I've read, it takes quite a lot (about 9MB). Sadly, this library (k4l-video-trimmer) is very old

Issue using Contact Group delete on Android

一个人想着一个人 提交于 2019-12-01 01:20:42
I have this code to delete a Contact Group public void delete(Activity act,String[] args) { try { int b=act.getContentResolver().delete(ContactsContract.Groups.CONTENT_URI,"_ID=?", args); Toast.makeText(act, "Deleted",Toast.LENGTH_SHORT).show(); //notify registered observers that a row was updated act.getContentResolver().notifyChange(ContactsContract.Groups.CONTENT_URI, null); } catch (Exception e) { Log.v(TAG, e.getMessage(), e); Toast.makeText(act, TAG + " Delete Failed",Toast.LENGTH_LONG).show(); } } I call the method like private void processDelete(long rowId) { String[] args = { String