android-contentresolver

Android kitkat Image Selection From Gallery Issue

≯℡__Kan透↙ 提交于 2019-12-23 05:32:29
问题 I have been trying to pick image from the gallery of Nexus devices..Since the Storage framework has been changed in kitkat 4.4 its been a headache for me to implement this functionality..I have referred to this link retrieve absolute path when select image from gallery kitkat android I am getting the path of the file in the gallery..and also decode the image and set it into the imageView..but as soon I do this..My app closes suddenly and again reconnects to the server and tells me to log in

Am I able to run SQL functions on a ContentResolver columns query?

送分小仙女□ 提交于 2019-12-22 10:19:58
问题 I am wondering if Android's ContentResolver supports using SQL functions over the columns when you query a ContentProvider. Such as SQLite3 date functions, to get a specific date format, or datediff? What do you know about this? 回答1: No. Even if you find it works for some cases, you cannot assume it works across the board. ContentProvider is a facade. A given ContentProvider might use SQLite. It might use XML files. It might use JSON files. It might use CSV files. It might use some third

Get real path from Uri - DATA is deprecated in android Q

拟墨画扇 提交于 2019-12-22 08:51:03
问题 I'm successfully implementing a method for retrieving the real path of an image from gallery by the Uri returned from ACTION_PICK intent. Here's a sample: // getRealPathFromURI(intent.getData()); private String getRealPathFromURI(Uri contentURI) { String result; Cursor cursor = getContentResolver().query(contentURI, null, null, null, null); if (cursor == null) { // Source is Dropbox or other similar local file path result = contentURI.getPath(); } else { cursor.moveToFirst(); int idx = cursor

Using ContentResolver instead of ContentProviderClient in SyncAdapter

╄→尐↘猪︶ㄣ 提交于 2019-12-22 04:42:49
问题 As I understand from the docs, one SyncAdapter defined in a SyncService is limited to receive only one ContentProvider authority to work on. But, at the same time, it has access to ContentResolver which it allows to run queries on other ContentProviders as well. I don't understand this particular design concept if a developer is needed to provide a single content authority to SyncAdapter and nonetheless she is able to do whatever she wants on whatever ContentProvider she has access to. My

Android - Find a contact by display name

落花浮王杯 提交于 2019-12-22 03:54:31
问题 I'm trying to find a contact by display name. The goal is to open this contact and add more data to it (specifically more phone numbers), but I'm struggling to even find the contact I want to update. This is the code I'm using: public static String findContact(Context context) { ContentResolver contentResolver = context.getContentResolver(); Uri uri = ContactsContract.CommonDataKinds.Phone.CONTENT_FILTER_URI; String[] projection = new String[] { PhoneLookup._ID }; String selection =

get last Call on CallLog using a Service

假如想象 提交于 2019-12-22 01:17:23
问题 I'm doing a program to send the CallLog to a Server, I created a Service that makes a poll of the telephone status with the following method. This method is called onCreate. private void pollForCallStatus() { timer.scheduleAtFixedRate(new TimerTask() { @Override public void run() { Log.d("Poll", Integer.toString(telephonyManager.getCallState())); switch (telephonyManager.getCallState()){ case TelephonyManager.CALL_STATE_RINGING: Log.d("CallService", "ringing"); break; case TelephonyManager

How can I call getContentResolver in android?

佐手、 提交于 2019-12-21 07:34:06
问题 I'm writing a library class to encapsulate some of my logic in my first Android app. One of the functions which I want to encapsulate is a function which queries the address book. As such, it needs a ContentResolver . I'm trying to figure out how to keep the library functions black-boxed... that is, to avoid having each Activity pass in its own context to get a ContentResolver . Problem is I cannot for the life of me figure out how to get a ContentResolver from within my library function. I

How to access sms time which I have received in inbox?

偶尔善良 提交于 2019-12-21 04:32:08
问题 I am able to read message from the inbox from this:-- Uri uriSMSURI = Uri.parse("content://sms/inbox"); Cursor cur = getContentResolver().query(uriSMSURI, null, null, null, null); i access date from this:- date = cur.getString(cur.getColumnIndexOrThrow("date")); But now problem is that it gives current time not Message Time from inbox. Sorry for Bad editing & any idea will be appreciated. Thanks in Advance! 回答1: Use this code: ContentResolver contentResolver = getContentResolver(); Cursor

Delete SMS with contentResolver is too slow

こ雲淡風輕ζ 提交于 2019-12-20 03:53:24
问题 I would like to delete all SMS on my phone except the 500 last SMS for each conversation. This is my code but it's very slow (take about 10 seconds to delete one SMS). How I can speed up this code : ContentResolver cr = getContentResolver(); Uri uriConv = Uri.parse("content://sms/conversations"); Uri uriSms = Uri.parse("content://sms/"); Cursor cConv = cr.query(uriConv, new String[]{"thread_id"}, null, null, null); while(cConv.moveToNext()) { Cursor cSms = cr.query(uriSms, null, "thread_id =

Android Calendar Specific Event Deletion

蓝咒 提交于 2019-12-19 09:07:35
问题 I have created an application that easily puts the values that I want to the the device's calendar but when I want to delete it from the calendar programmatically I can't find a way how to. I've searched the net, mostly other stackoverflow questions, to find an answer (links here): Delete Calendar Entry, Events from Calendar not Deleted, Delete Specific Event. I found a way to delete all event entries on the calendar: public void onClick(View v) { Uri eventsUri = Uri.parse("content://com