i'm trying to access alarm provider to get all enabled alarm information.
so i wrote this :
public static final Uri CONTENT_URI =
Uri.parse("content://com.android.deskclock/alarm");
ContentResolver cr = getContentResolver();
Cursor c = null;
c = cr.query(
CONTENT_URI, ALARM_QUERY_COLUMNS,
null, null, DEFAULT_SORT_ORDER);
but it seemed to have the permission problem??
it always crashed QQ......could someone help me?
As #CommonsWare points out this only works on certain devices. Although with the other alarm URIs it was possible to read on most platforms. However in Honeycomb they have changed the access required and you can no longer use a content provider to get to the alarms.
Related
I am a newbie. I try to get data(content, title ....) of memo app on Samsung phone. I used to "content://com.samsung.android.memo". My app is crashed and show message
java.lang.SecurityException: Permission Denial: opening provider com.samsung.android.app.memo.model.provider.memo.MemoProvider from ProcessRecord{9d45db 22489:com.example.kenshin.internetsamsung/u0a199} (pid=22489, uid=10199) requires com.samsung.android.memo.READ or com.samsung.android.memo.WRITE
After I add uses-permission on AndroidManifest.xml. but it still crashed. Please give me a advice. Thanks
"uses-permission android:name="com.samsung.android.memo.WRITE" and
"uses-permission android:name="com.samsung.android.memo.READ"
final Uri uri = Uri.parse("content://com.samsung.android.memo");
final Cursor c = getContentResolver().query(uri, null, null, null, null);
I need help in accessing the attachment received in an email.
I have setup intent filter for my activity and on clicking the attachment in the gmail app, my activity is launched with intent containing following Uri.
content://gmail-ls/xxxx#gmail.com/messages/2407/attachments/0.1/BEST/false
I have tried following query and filename returned is null.
String[] projection = {MediaStore.MediaColumns.DATA};
Cursor c = context.getContentResolver().query(uri, projection, null, null, null);
if (c.moveToFirst()) {
fileName = c.getString(0);
}
Anyone, please let me know how can I access the file received in the attachment ?
Thanks.
Anyone, please let me know how can I access the file received in the attachment ?
There isn't necessarily a file at all, let alone one that you have direct access to. Gmail, in particular, had better be storing its attachments in a place where other apps cannot access them directly.
To use the attachment, use the Uri with a ContentResolver to get an InputStream on it.
I want to get the Contact Numbers based on the Search word.
I tried using the following, but it gives Unknown URL exception.
Uri uri = Uri.withAppendedPath(ContactsContract.Contacts.CONTENT_FILTER_URI, partOfContactName.toString());
Cursor cursorContact = getApplicationContext().
getContentResolver().query(uri,
new String[] {ContactsContract.CommonDataKinds.Phone.NUMBER}, null, null, null);
By using the above code base I am getting the following exception.
01-03 11:11:38.225: ERROR/AndroidRuntime(711): Caused by: java.lang.IllegalArgumentException: Unknown URL content://com.android.contacts/contacts/filter/
So is there any way to get this done ?
This application is for the devices having Android 2.1+
try this by replacing your uri line.: Uri uri = Uri.withAppendedPath(ContactsContract.CommonDataKinds.Phone.CONTENT_URI, partOfContactName.toString());
I've read related several questions here and can't find the answer to this: I have an Android 2.1 device (HTC Incredible). My app, however, must be compatible with early (pre SDK 5) devices, so I am using the deprecated format of filter URI:
Uri contactUri = Uri.withAppendedPath(Contacts.Phones.CONTENT_FILTER_URL, Uri.encode(number));
Cursor C = context.getContentResolver().query(contactUri , null, null, null, null));
The number is of the form 15555551212. This fails to find the Contact, at least on my device. However, changing to the new (SDK 5 and later) ContactsContract format URI
Uri contactUri = Uri.withAppendedPath(ContactsContract.PhoneLookup.CONTENT_FILTER_URI, Uri.encode(number));
Cursor C = context.getContentResolver().query(contactUri , null, null, null, null));
results in success. Originally, the corresponding number in the Contact was in the format +1 555 555 5555, but I changed it to exactly match the input number 15555555555 and the old format URI still fails. In both cases, the new format URI succeeds.
Does anyone have any thoughts as to why this is the case? I'm stumped!
That was it. The old API just won't do. Needing to be compatible with older devices, I used Reflection to laod and use the new API calls (ContactsContract) on API > 4.
I've problem when I want to read com.android.email.provider to
get email accounts.
Here is my code to retrieve the account :
Cursor c = null;
Uri CONTENT_URI = Uri.parse("content://com.android.email.provider/account");
String RECORD_ID = "_id";
String[] ID_PROJECTION = new String[] {RECORD_ID };
c = getContentResolver().query(CONTENT_URI,ID_PROJECTION,null, null, null);
I got a security exception:
java.lang.SecurityException: Permission Denial: reading com.android.email.provider.EmailProvider uri content://com.android.email.provider/account from pid=278, uid=10003 requires com.android.email.permission.ACCESS_PROVIDER
I want to know the account is created or not in some other app. Is there any other way to resolve this so that I can read from the provider.
I have also tried adding the permission in manifest:
<uses-permission android:name="com.android.email.permission.ACCESS_PROVIDER"/>
That didn't help.
Any solution would be greatly appreciated.
Thanks in advance
I'm afraid, it's impossible. See, here http://androidbridge.blogspot.com/2011/03/reading-emails-in-android.html