android-contentprovider

Multiprocess Content Providers synced to default one

*爱你&永不变心* 提交于 2019-12-05 01:26:14
According to Android documentation : android:multiprocess Whether or not an instance of the content provider can be created in every client process — "true" if instances can run in multiple processes, and "false" if not. The default value is "false". Normally, a content provider is instantiated in the process of the application that defined it. However, if this flag is set to "true", the system can create an instance in every process where there's a client that wants to interact with it, thus avoiding the overhead of interprocess communication. Therefore, if this attribute is set to true then

Query using MockContentResolver leads to NullPointerException

烈酒焚心 提交于 2019-12-05 00:47:28
问题 We have a JUnit test class which extends ActivityInstrumentationTestCase2<CommentActivity> . The test (and the class we're testing) use CommentContentProvider , which extends ContentProvider , to access the SQLite database, and we're getting a NullPointerException [full stack trace below] when running a query on the provider. We instantiate a MockContentResolver as shown: MockContentResolver mResolver; public void setUp() { super.setUp(); CommentContentProvider ccp = new

SQLiteConstraintException: error code 19: constraint failed — Android error

懵懂的女人 提交于 2019-12-04 22:56:32
I have seen some other questions about this, but none of the answers really seemed to work for my code. I'm getting a 'SQLiteConstraintException: error code 19: constraint failed' error when I try to insert into my DB. Here is the code for the insert operation. db.insert returns a -1 right now, which leads to the "failed to insert" message. Here is the the relevant Content Provider code: public static final String PROVIDER_NAME = "com.oliverapps.provider.DB"; public static final Uri CONTENT_URI = Uri.parse("content://"+ PROVIDER_NAME + "/tasks"); public static final String _ID = "_id"; public

How to provide content for Intent.ACTION_GET_CONTENT

核能气质少年 提交于 2019-12-04 21:45:21
问题 The web and stackoverflow contain several examples how to get a file from another Android app (e.g., to use it as email attachment) using an ACTION_GET_CONTENT intent. But what kind of class do I have to implement to create an application providing content for the ACTION_GET_CONTENT event such as I can choose this app (e.g., for selecting an email attachment). Is a ContentProvider the right solution? And what do I have to add to my AndroidManifest.xml? 回答1: After some hours of web search I

Android Web browser homepage

回眸只為那壹抹淺笑 提交于 2019-12-04 20:25:17
问题 I have seen several apps and advertising networks like startapp changing the android web browser homepage by code. How is this possible? I have taken a look at the startapp sdk but i have not managed to find the part where they change the homepage. I have also taken a look at the BrowserSettings in com.android.browser.BrowserSettings In BrowserSettings , there is a interface called setHomepage(Context, String) . public void setHomePage(Context context, String url) { Editor ed =

MMS CONTENT PROVIDER ISSUE (Samsung Galaxy S3)

不羁岁月 提交于 2019-12-04 20:12:57
We run into the following crash when we attempt to query "content://mms-sms/conversations/" on a Samsung Galaxy S3 (Android 4.0.4) running on the Sprint network. Our calling code: Uri uri = Uri.parse("content://mms-sms/conversations/"); Log.e("IL", "CONTENT MIME " + context.getApplicationContext().getContentResolver().getType(uri)); // The next call crashes... Cursor cursor = context.getApplicationContext().getContentResolver().query(uri, null, null, null, null); The interesting fact is that the log above returns CONTENT MIME vnd.android-dir/mms-sms as expected. Stack trace below: Caused by:

Does Android Content Provider authority definition break the DRY rule?

不羁的心 提交于 2019-12-04 18:09:00
Android's Content Provider must have : At least one authority must be specified. So for example in Google's samples android-BasicSyncAdapter AndroidManifest.xml there is <provider android:name=".provider.FeedProvider" android:authorities="com.example.android.basicsyncadapter" android:exported="false" /> Then to implement this CP one need to define the same String inside the CP like in android-BasicSyncAdapter FeedProvider.java CONTENT_AUTHORITY public static final String CONTENT_AUTHORITY = "com.example.android.basicsyncadapter"; As we have to define this String twice, isn't this basically

Android get sms from inbox, optimized way to read all messages and group them

痴心易碎 提交于 2019-12-04 17:37:40
问题 Hi am implementing a SMS App, now am able to retrieve all messages with their respective contact info like display name, photo uri.. and am displaying them in a custom list where on item click takes you to respective discussion. Here my issues is the time taking to sync all these messages, I need to optimize this time. Each time i send a new message in the discussion view and go back to recent chats i need to only update the particular item, not the whole list. Here's my code: ReadSMS.java:

access user dictionary android

荒凉一梦 提交于 2019-12-04 17:13:56
Hi this is my code to get the words from the user dictionary. this is my code but i am not able to run it... private String getwordlist() { String[] mSelectionArgs={""}; String[] mProjection ={UserDictionary.Words._ID, UserDictionary.Words.WORD, UserDictionary.Words.FREQUENCY}; String mSelectionClause = null; String mSortOrder = null; mCursor = getContentResolver().query( UserDictionary.Words.CONTENT_URI, // The content URI of the words table mProjection, // The columns to return for each row mSelectionClause, // Either null, or the word the user entered mSelectionArgs, // Either empty, or the

nullPointerException with extended SimpleCursorAdapter

百般思念 提交于 2019-12-04 17:00:48
I'm learning about custom providers and loaders. As a simple example I'm trying to implement a GridView that shows the pictures stored in the external SD card. Although I've read a lot (documentation, threads on SO, Google groups, forums...) I'm not able to get my code working. I know that several issues may be present on this example but I want to go step by step. The first error stopping the code is a NullPointerException , so my question is how to fix it. This is a minimal version of my Activity (it uses support library v4): public class MainActivity extends FragmentActivity implements