android-contentprovider

How do I get the file path from the content URI for video files?

喜欢而已 提交于 2019-12-02 03:39:24
I want to attach images or video files from the Android storage. When I select a video from the gallery, it returns the content uri path . How do I get the file path with extension from the content URI? I tried following code, but it returns null in lollipop: void pickVideo() { Intent videoIntent = new Intent(Intent.ACTION_GET_CONTENT); videoIntent.setType("video/*"); startActivityForResult(videoIntent, PICK_VIDEO_FILE); } @Override public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); try { if (resultCode !=

getContentResolver().openOutputStream(uri) No files supported by provider

青春壹個敷衍的年華 提交于 2019-12-02 02:58:56
I want store a file audio in my personal content provider. i save record: Uri uri = getContentResolver().insert(CONTENT_URI, values); OutputStream os = getContentResolver().openOutputStream(uri); but getContentResolver().openOutputStream(uri); throws: 10-13 19:44:53.903: ERROR/TAB(5679): No files supported by provider at content://com.memento.data.provider.MementoProvider/audionotes/6 10-13 19:44:53.903: ERROR/TAB(5679): java.io.FileNotFoundException: No files supported by provider at content://com.memento.data.provider.MementoProvider/audionotes/6 10-13 19:44:53.903: ERROR/TAB(5679): at

Samsung device returns text messages when querying for call-log

匆匆过客 提交于 2019-12-02 00:49:11
问题 Some of my users report that on their Samsung devices (GT-N7000 & SGH-I777) a query I make in my app for the CallLog.Calls displays also text messages. I've created a dump of their CallLog ContentProvider , and it seems to have extra fields not mentioned in the Android API, and not returned on any of our test devices. Specifically, looking through the dump, there's a field called logtype , which seems to equal 100 for calls, and 300 for text messages. Having searching online for this field, I

Update contact image in android contact provider

ε祈祈猫儿з 提交于 2019-12-01 21:29:00
问题 I create an Application to Read, Update, Delete Contacts Details. Here is a problem to updating Contact_Image. When new contact Added by device outside the Application without image. then we can't update contact Image. My Updating Code is. ops.add(ContentProviderOperation.newUpdate(Data.CONTENT_URI) .withSelection(Data.CONTACT_ID+"= ? AND "+ContactsContract.Data.MIMETYPE+"=?",new String[]{id,ContactsContract.CommonDataKinds.Photo.CONTENT_ITEM_TYPE}) .withValue(ContactsContract.CommonDataKinds

Android / Java convert String date to long type

纵然是瞬间 提交于 2019-12-01 17:27:28
问题 I need to convert a string in the format "dd/mm/yyyy", to a long type. In order to pass the value to the calendarProvider in android. Currently I have: Calendar calendar = Calendar.getInstance(); long startEndDate = 0; Calendar currentDateInfo = Calendar.getInstance(); currentDateInfo.set(calendar.get(Calendar.YEAR), calendar.SEPTEMBER, calendar.get(Calendar.DAY_OF_MONTH)); startEndDate = currentDateInfo.getTimeInMillis(); I need: long startDate = *Some sort of conversion* EditText.getText();

How to share internal storage file with Gmail Client

▼魔方 西西 提交于 2019-12-01 16:24:03
I am trying to share my internal storage file via Gmail client on my Moto Razr, but every time I sent to my test gmail account, I got everything except attachment. This is how I invoke and start gmail, while add file as attachment. private void saveDaily() { Intent intent = new Intent(android.content.Intent.ACTION_SEND_MULTIPLE); intent.setType("text/plain"); intent.putExtra(Intent.EXTRA_EMAIL, new String[] { loadEmailAddress() }); intent.putExtra(Intent.EXTRA_SUBJECT, "Daily"); intent.putExtra(Intent.EXTRA_TEXT, "Daily Log"); intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); ArrayList

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

Content Provider Example using two android applications

折月煮酒 提交于 2019-12-01 14:16:07
I want to insert or delete the values in another android applications database from my current android application. I searched a lot. Everybody saying that use " content provider " its not used with two applications all used with in a application. here i found some examples/tutorial for you, Please have a look , below tuts include everything you can do to create content provider. Android Fundamentals: Working With Content Providers . example1 Assuming that you have a database and a content provider in your application.... You can use the database of other application if it is exported. To

Check Incoming number is stored in Contacts list or not android

瘦欲@ 提交于 2019-12-01 11:15:31
In my android app when an incoming call i want to show my custom ui and i am able to do this. No i want to check incoming number is from contacts or not. Below is my code for doing so but it returns null for an incoming number which is stored in my contacts list. public String findNameByNumber(String num){ Uri uri = Uri.withAppendedPath(Phones.CONTENT_FILTER_URL, Uri.encode(num)); String name = null; Cursor cursor = mContext.getContentResolver().query(uri, new String[] { Phones.DISPLAY_NAME }, null, null, null); if (cursor != null && cursor.moveToFirst()) { name = cursor.getString(cursor

What is the expected behavior of SQLite CRUD operations after a configuration change or if the activity that started those operations is destroyed?

為{幸葍}努か 提交于 2019-12-01 08:14:40
问题 I'm refactoring an app I made some time ago. Back then I was taking my first steps into Android and the easy way to go was to avoid orientation changes, for almost all my CRUD operations I used the AsyncTask class, didn't implement a Content Provider or used Fragments. Now I have made some changes: I use Fragment s to encapsulate functionality All accesses to my database are done through a Content Provider I use CursorLoader s to retrieve my data taking advantage of the content observation