FAQ Database Discussion Community


Content loader reverse cursor order

android,android-contentprovider
I have a simple chat application. I am using content loaders to display messages inside a channel. Since I want 100 recent messages I sort messages based on the time stamp desc and limit it to 100. but I want to display recent messages at the bottom of the screen....

Custom ContentProvider suggestions not displaying

android,android-contentprovider,searchview,search-suggestion
My goal: Implementing search within an application. How it should work: I have multiple activities which have a SearchView within their Action Bar (or Toolbar as they now call it), and a dedicated Search activity. I want to be able to input text in the SearchView, receive suggestions while i...

Bi-Directional Sync on Android Using SyncAdapter

sqlite,synchronization,android-contentprovider,android-syncadapter
I am planning to create sqlite table on my android app. The data comes from the the server via webservice. I would like to know what is the best way to do this. Should I transfer the data from the webservice in a sqlite db file and merge it or...

How to play a video from Content Provider

android,video,android-contentprovider,videoview
I might have been using the wrong search tags, but here it goes. In the App I'm developing the user is able to upload pictures and videos. This through recording or gallery. I'm currently trying to show a video which the user just recorded. I'm taking the Uri from Intent.getData()...

Accessing Android Content Provider inside Webview

html5,android-webview,android-sqlite,android-contentprovider
In Android. How do you access Content Provider inside your webview. It is showing content uri as not defined google.visualization.Query(CONTENT_URI, opt_options); ...

Android UriMatcher doesn't match wildcards

android,regex,android-contentprovider
I have a ContentProvider and I need to match some URIs containing UUIDs as wildcards. UriMatcher from ContentProvider: public static final Uri CONTENT_URI_NOTIFICATIONS = Uri.parse("content://" + AUTHORITY + "/" + BASE_PATH_NOTIFICATIONS); public static final Uri CONTENT_URI_USERS = Uri.parse("content://" + AUTHORITY + "/" + BASE_PATH_USERS); private static final int NOTIFICATIONS =...

Android Studio - Cannot resolve symbol FacebookContentProvider

android,maven,android-studio,android-contentprovider,facebook-android-sdk
I'm using the Facebook SDK 3.22.0 from Maven. Building for Android SDK version 15. I'm also using Android Studio 1.1.0 with Gradle. In AndroidManifest.xml I'm trying to use the FacebookContentProvider, but every time I try, I get the issue Cannot resolve symbol FacebookContentProvider. Any ideas on how to solve this?...

Is global search in android still available for developer?

android,android-contentprovider,android-search,searchable
I'm stuck for adding global search to my app. I did everything that I should do. my question is is global search is still available for developer? I read somewhere that Google replaced it with index. Thank you for your time and help...

Getting java.lang.ClassCastException: android.widget.FrameLayout$LayoutParams cannot be cast to android.widget.RelativeLayout$LayoutParams

android,android-layout,android-contentprovider,classcastexception,android-relativelayout
Here I need to add textview at runtime. first I took reference of RelativeLayout to get layout params but unfortunately its throwing ClassCastException at RelativeLayout.LayoutParams params = (android.widget.RelativeLayout.LayoutParams)contentLayout.getLayoutParams() I also checked - FrameLayout to RelativeLayout ClassCastException even if there is no FrameLayout used, but it didn't work. Since after replacing...

What is the best way to use the insert, delete and update from an Content Provider?

android,android-asynctask,android-contentprovider,crud,loader
I am spinning my head around this theme for quite some time. I don't have much experience with Android and I'm trying to code everything using the best approach I can. I successfuly created a Content Provider to wrap my SQLite and some Loaders to query the Data. It works...

Android ContentProvider Uri Issue ( Unknown URL content )

java,android,android-studio,android-contentprovider
Haloa ^^ I have the following issue : 02-16 21:08:13.550 2350-2350/com.tutos.android.content.provider E/ActivityThread﹕ Failed to find provider info for com.tutos.android.content.provider.androidprovider 02-16 21:08:13.550 2350-2350/com.tutos.android.content.provider D/AndroidRuntime﹕ Shutting down VM 02-16 21:08:13.550 2350-2350/com.tutos.android.content.provider E/AndroidRuntime﹕ FATAL EXCEPTION: main Process: com.tutos.android.content.provider, PID: 2350 java.lang.RuntimeException: Unable to start activity...

Android CallLog Content Provider raises java.lang.IllegalArgumentException

java,android,android-contentprovider
I'm trying to access information from the Android CallLog Content Provider, using the code that follows, but it raises an exception java.lang.IllegalArgumentException: Cannot bind argument at index 1 because the index is out of range. The statement has 0 parameters. // Designates which columns to get back from the content...

Android;use “ContentProvider” to download from web server

android,android-asynctask,android-contentprovider
Is it possible to use ContentProvider for retrieving(query) data from web server? Some data that are used in App are stored locally and some others stored in web server,I want to encapsulate retrieving data and also storing data by ContentProvider. Obviously retrieving local data is simple and may be done...

Saving Populated Listview Items on disk and reloading them when App is launched

android,listview,serialization,android-contentprovider
In my android application, I have a list view. Each list view item has some text and text and a bitmap. This list is population with content from my back-end each time I start the app. What I want to do is to save the these populated items onto disk...

ListView won't update even if I call notifyChange(uri, null); though content provider

android,android-contentprovider,android-cursoradapter
I'm having trouble trying to get my ListView to refresh when new data gets added to the content provider. Reading similar posts on this issue, I made sure to use getContext().getContentResolver().notifyChange(uri, null); on my insert method and c.setNotificationUri(getContext().getContentResolver(), uri); on my query method (talking about the content provider class). I...

Updating DB from onLoadFinished calls onLoadFinished again and again

android,cursor,android-contentprovider,loader,android-cursorloader
I have a situation in which I need to insert a row at a date and update all the entries after a particular date in an Activity For this, I thought I'll load the entries after the date with a LoaderManager Callback and use a ContentProviderOperation array to update all...

Android Loader used with SimpleCursorAdapter and ContentProvider not updating

java,android,android-contentprovider,android-listfragment,loader
I have a list fragment which loads data from a ContentProvider using a Loader and SimpleCursorAdapter. I think that I have followed correctly the directions given by google examples, but my ListView is not updated when underlying data changes. This is what I'm doing: ContentProvider @Override public synchronized Cursor query(Uri...

Android, pass a parcelable array or fetch data again from Content Provider?

android,android-fragments,bundle,android-contentprovider,parcelable
Bit of a performance question. I have a fragment that fetched some data from the content provider and built an object which implements Parcelable. MyObject object; In the scenario where such objects is required in another fragment, what would be more convenient: pass the object as args.putParcelable(ARG_KEY_OBJECT, object); or pass...

Should I use a Cursor or a CursorLoader?

android,android-studio,android-contentprovider,android-contentresolver
I have an android app in which I have a login system and some other stuff that communicate with the server. Sometimes I just get from the web server just a confirmation and sometimes I get a lot of data. So far I was using a simple database. Today I...

Secure downloaded Files in android applications with internal storage and encrypting usage?

android,encryption,android-contentprovider,internal-storage
I am working on an Android application which downloads files in External storage. I want to download them in internal storage and encrypt them so they become secure even with a rooted device. I found that we can work with internal storage and encrypting the files and to use them...

OnLoadFinished called infinitely

android,android-contentprovider,loader
Yesterday I try to write my content provider and to test it. Unfortunately, this piece of code: if(loader.getId() == 1) getContentResolver().insert(Uri.parse("content://com.example.djak.contentprovidertest.provider/cte"), values); does something, because of which onLoadFinished is called infinitely. Has someone idea what is going on? When I remove it onLoadFinished is called only once. And when onLoaderReset...

Android Album Art from MediaStore (and Picasso)

android,android-contentprovider,picasso,mediastore,albumart
Trying to retrieve the path to the album art for each album in MediaStore. I'm retrieving my cursor like this: String[] projection = new String[] {MediaStore.Audio.Albums._ID, MediaStore.Audio.Albums.ALBUM_ART, MediaStore.Audio.Albums.ALBUM, MediaStore.Audio.Albums.ARTIST}; // Returns a new CursorLoader return new CursorLoader(getActivity(), MediaStore.Audio.Albums.EXTERNAL_CONTENT_URI, projection, null, null, MediaStore.Audio.Albums.ALBUM + " ASC"); Which returns a valid cursor...

Permisssion denied while attaching apk file with GMail app android

android,gmail,android-contentprovider,permission-denied,android-permissions
I have a requirement to send a apk file through share Intent and I have also implemented without any hassle. But the problem arises only while sending apk via GMail, I am getting permission denied while i try to attach. I really dont know what is happening with GMail. Kindly...

How do implicit joined columns work with Android contacts data?

android,android-contentprovider,contacts,android-contacts,contactscontract
I'm querying the ContactsContract.Data table to find phone records. I get an error when I create a new CursorLoader: java.lang.IllegalArgumentException: Invalid column deleted My code: import android.provider.ContactsContract.CommonDataKinds.Phone; import android.provider.ContactsContract.Data; ... String[] projection = { Phone.DELETED, Phone.LOOKUP_KEY, Phone.NUMBER, Phone.TYPE, Phone.LABEL, Data.MIMETYPE, Data.DISPLAY_NAME_PRIMARY }; // "mimetype = ? AND deleted = ?"...

How to Add a contact with Data of Birth into device contacts programatically?

android,android-contentprovider,android-contacts
I am using the following code for inserting a contact, but i am unable to find the Date_Of_Birth field to add it. ContentValues values = new ContentValues(); values.put(Data.MIMETYPE, Phone.CONTENT_ITEM_TYPE); values.put(Phone.NUMBER, "0123456789"); values.put(Phone.TYPE, Phone.TYPE_CUSTOM); values.put(Phone.LABEL, "Ravi"); Uri dataUri = getContentResolver().insert(android.provider.ContactsContract.Data.CONTENT_URI, values); ...

Creating contact with country code in Android

android,android-contentprovider,android-contacts
I have some problem when adding a contact to Content Provider with number prefixed with country code, for example "+48515000111". Adding this kind of number causes that my contact have number like "48515000111" so the "+" character is removed. This is how I add a contact : ArrayList<ContentProviderOperation> ops =...

why i can't get the right result when I using ContentResolver.update?

android,android-contentprovider
I'd recently learned Content provider in android.I tried to implement ContentProvider.When I perform updating ,it felt more like deleting than updating. public void updateBook(Context context){ String name=edName.getText().toString(); String isbn=edIsbn.getText().toString(); String author=edAuthor.getText().toString(); //String msg="name:"+name+",isbn:"+isbn+",authro"+author; String tag="Exercise BookProvider"; Log.d(tag, "updating a book"); ContentValues cv=new ContentValues(); cv.put(BookProviderMetaData.BookTableMetaData.BOOK_NAME,...

Why doesn't the subtype of this custom MIME type specify the particular row (from Content URI) in the table?

android,uri,android-contentprovider,mime-types
AT the end of the developer guide, they have described vnd.android.cursor.dir to be the type part of every custom MIME type, for multiple rows; and vnd.android.cursor.item for a single row. Then there is an example of a Content Provider that contains train timetables. It's authority is com.example.trains and it has...

SQLite data to a RecyclerView

android,android-sqlite,android-contentprovider,recyclerview,android-cursorloader
The app has data in a SQLite database. The UI is primarily a RecyclerView. The question is how to best to transfer data from the database into the UI, whilst keeping off the main thread? I originally planned to use a CursorLoader, ContentProvider, and RecyclerView. But reading around it looks...

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

android,permissions,android-manifest,android-contentprovider,android-contentresolver
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...

distinguish between answered and unanswered outgoing calls (android)

android,android-intent,android-contentprovider,contentobserver
I want to find out if an outgoing call has been answered. Unfortunately, in the case of an outgoing call I see Intent { act=android.intent.action.PHONE_STATE flg=0x10 (has extras) } extras:Bundle{ state => OFFHOOK; }Bundle Intent { act=android.intent.action.PHONE_STATE flg=0x10 (has extras) } extras:Bundle{ state => IDLE; }Bundle regardless of whether or...

Why is this variable set to empty string when it is already initialized to an empty string?

java,android,android-contentprovider,android-contentresolver
I have taken the following code snippet from the 5th snippet on this developer guide on Content Providers. The confusion is that in the first statement String[] mSelectionArgs = {""};, mSelectionArgs[0] IS set to "". Then later if the mSearchString is empty (TextUtils.isEmpty(mSearchString)), then again mSelectionArgs[0] is assigned "". So...

Can't access a customProvider from another app. It says it's missing permissions it already has

android,sqlite,android-contentprovider
I'm trying to make an app that access a SQLite table from another app with a custom content provider. I'm getting the following error: java.lang.SecurityException: Permission Denial: reading com.example.carlos.gymlog.MiContentProvider uri content://mi.uri.porquesi/sesiones from pid=2375, uid=10064 requires android.permission.permRead, or grantUriPermission() However, my "sender" app (the one with the database) already has the...

Failed to find provider info error

android,android-contentprovider,android-contentresolver
I am trying to have a contentprovider , but I am having trouble because I am getting an error of "Failed to find provider info for com.example.alex.hopefulyworks" Here is the manifest and the contentprovider <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.alex.hopefulythisworks" > <application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" > <activity...

The difference between authority and scheme in an Android URI

android,uri,android-contentprovider,authority
What is the difference between URI authority and URI scheme in Android? I always use scheme in URI to indicate database table as follow: content://scheme I using custom search suggestion in my application, I read document about search custom suggestion in which authority used instead of scheme to reference database...

android getContentResolver().notifyChange() does not restart my loader

android,android-contentprovider,android-contentresolver,android-loadermanager,android-loader
codes: First my Uris public static final String PACKAGE = "my.url.contentprovider"; public static final String TABLE_NAME = "NetworkTransaction"; public static final String AUTHORITY = PACKAGE + ".NetTransContentProvider"; public static final Uri BASE_URI = Uri.parse("content://"+AUTHORITY); public static final Uri CONTENT_URI_ANY_OBSERVER = Uri.withAppendedPath(BASE_URI,TABLE_NAME+"/*"); public static final Uri CONTENT_URI_FIND_BY_ID = Uri.withAppendedPath(BASE_URI,TABLE_NAME+"/FIND/ID"); public static...

Delete number from all contacts

android,android-contentprovider,android-contentresolver
The following query fails and I am not sure why. It is supposed to delete all numbers occuring in the string list passed to the method. I first suspected the MIME type but leaving out " LIKE ? AND " + Data.MIMETYPE + " = ?" wouldn't solve it either....

API support for the Default SMS app

android,sms,android-contentprovider
I have some doubts about the Android Default SMS app. I have to create an app that will need to read/write SMS and MMS in the Android SMS/MMS database. To do that I will need to use the "content://sms/***" Content Provider. This Content Provider is not part of the SDK...

Android conflict after change package name. build.graden - > applicationId || Provider

android,sqlite,android-contentprovider
I created an app with Android Studio and I have a problem now. To publish the app I have to change the package names so I have changed it.(before: com.example..). The app it's working perfect but in the build.graden the applicationId still having com.example. So when I change it I...

Android: How do I change the style of recent queries list in a SearchView?

android,android-contentprovider,android-styles,searchview
I implemented a recent queries Content Provider for my Searchable Configuration and it works, but how do I change the style of the list? It came with white text on light background, I'd like to change at least the color of text. Thank you for your help!...

Android Contacts Content Provider sometimes returns empty phone numbers

android,android-contentprovider,android-contacts,android-cursor
Here is the code used to get the contact information : String id = data.getData().getLastPathSegment(); Cursor cursor = getActivity().getContentResolver() .query(ContactsContract.Data.CONTENT_URI, new String[] {ContactsContract.Data.DISPLAY_NAME}, ContactsContract.Data.CONTACT_ID + "=?", new String[]{id}, null); // short circuit if we didn't pick a contact if (cursor.getCount() == 0) { return; } String contact = ""; String...

how do URIs with “file” scheme work in Android

android,android-contentprovider
I know that in Android I can read files from disk this way: Uri uri = Uri.parse("file:///data/data/com.example.mytest.mytest/test.txt"); InputStream stream = getContentResolver().openInputStream(uri); int i; while ((i = stream.read()) != -1) { Log.i("@@@", "znak: " + i); } However, I don't know how it works. Does exist in Android some content provider...

Android content uri id as string

android,mongodb,sqlite,uri,android-contentprovider
In my Android app i use SQLite with content provider. For some (backend) reasons, my tables have _id primary key as VARCHAR. The problem is: I need to use content uri with appended id. In all examples what i saw content uri with id looks as content://<autority>/<model_or_table>/<long_id> and adds to...

CursorLoader, unsubscribe from ContentProvider notifications

java,android,cursor,android-contentprovider,android-cursorloader
I'm using a CursorLoader to query a ContentProvider to populate a ListView, with the following code (wrapped in a LoaderManager): CursorLoader loader = new CursorLoader(getActivity(), Provider.CONTENT_SOME_URI, projection, selection, null, null); And an AsyncQueryHandler to update SOME_VALUE for a given _id triggered on click on a CheckBox placed on every single...