android-contentprovider

Correct implementation of asynchronous Android SQLite database

佐手、 提交于 2019-12-05 23:55:23
I've Googled around and have found multiple ways of accessing a local SQLite database asynchronously: AsyncTask CursorLoader (I've already used this for a query to retrieve my contacts information, but I'm not sure how this will translate to a SQLiteOpenHelper subclass with multiple queries) ContentProvider - Not sure if it's overkill, the database will only be need from within the app What is the best practice? I currently have a SQLiteOpenHelper subclass which contains the basic table creation/upgrade/etc. logic. CursorLoader only supports queries. You may still want to use it and leverage

How to securely share data between two or more applications in android?

徘徊边缘 提交于 2019-12-05 22:58:31
问题 I am making an application framework for the enterprise environment which involves data sharing between two or more applications from the device memory . This data needs to be stored on the device and accessible to only a few applications (which can be identified by the certificates used to install them) . Also, it needs to be stored in a secure way so as to be not accessible to other third party applications . Which is the best way to implement this functionality ? I have read up about

Inserting a new contact programmatically through my app without using Intent

て烟熏妆下的殇ゞ 提交于 2019-12-05 22:47:03
I am working with an app in with I am interacting with phone contacts. I want to add a new Contact to my phones Contacts List. I have tried the following code but it is not work: void addContact(Context ctx, PreviewContactModel model) { ArrayList<Contact_Model> contact_models = handler.getAllContacts(); Contact_Model contact_model = new Contact_Model(); ArrayList<ContentProviderOperation> contentProviderOperation = new ArrayList<>(); int rawContactID = Integer.parseInt(contact_models.get(contact_models.size() - 1).getContactId()) + 1; contact_model.setContactId(String.valueOf(rawContactID));

Whats the correct way to save a file when using the Content sheme?

隐身守侯 提交于 2019-12-05 21:50:25
I use the following intent to allow the user to choose where a file should be saved: // https://developer.android.com/guide/topics/providers/document-provider var intent = new Intent(Intent.ActionCreateDocument); intent.AddCategory(Intent.CategoryOpenable); intent.SetType("image/png"); intent.PutExtra(Intent.ExtraTitle, "myfile"); StartActivityForResult(Intent.CreateChooser(intent, "Select Save Location"), 43); It creates the file and returns the file's uri: content://com.android.providers.downloads.documents/document/436 But now I am left hanging because that section of the documentation ends

How to marshal/unmarshal ContentValues to insert generic type into ContentProvider?

半腔热情 提交于 2019-12-05 19:00:21
I want to put a generic POJO into ContentValues and unmarshall it within the ContentProvider. I've been wracking my tiny brain re: Parcelables, ContentValues, and inserting into SQLite Regarding: http://njzk2.wordpress.com/2013/05/31/map-to-contentvalues-abusing-parcelable/ How to write a common code for inserting data in android's Sqlite I've been trying to insert a android.location.Location into SQLite via ContentProvider: Location loc = mLocationClient.getLastLocation(); myParcel = android.os.Parcel.obtain(); loc.writeToParcel(myParcel, 0); ContentValues values = ContentValues.CREATOR

How to generate a content provider with GreenDao 3?

╄→гoц情女王★ 提交于 2019-12-05 18:32:28
In GreenDao 2.x., there was a method called Entity.addContentProvider() which generated a ContentProvider for an entity. How to do the same in GreenDao 3.x? With the same method Entity.addContentProvider() I am able to generate the content provider in GreenDao 3. 来源: https://stackoverflow.com/questions/38935475/how-to-generate-a-content-provider-with-greendao-3

How to get bitmap providing a URI, java.io.FileNotFoundException: No content provider: /sdcard/Hello/1310610722879.jpg

谁说我不能喝 提交于 2019-12-05 17:56:05
问题 I've read the example to do this: protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (resultCode == RESULT_OK) { Uri imageUri = data.getData(); Bitmap bitmap = MediaStore.Images.Media.getBitmap(this.getContentResolver(), imageUri); } } But i get java.io.FileNotFoundException: No content provider: /sdcard/Hello/1310610722879.jpg My code is here: Uri uri1 = Uri.parse(Config.getPhotoPath(this)); try { Bitmap

What the appropriate replacer of deprecated “ managedQuery”?

守給你的承諾、 提交于 2019-12-05 17:22:58
问题 Android documentation said: This method was deprecated in API level 11. This is code: class GridViewActivity_ extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.gridview); GridView gv = (GridView)findViewById(R.id.gridview); Cursor c = managedQuery(Contacts.CONTENT_URI, null, null, null, Contacts.DISPLAY_NAME); String[] cols = new String[]{Contacts.DISPLAY_NAME}; int[] views = new int[] {android.R.id

ListActivity doesn't update as data arrives

百般思念 提交于 2019-12-05 16:54:47
I'm building a small application that I'd like to automatically update when new data arrives. From what I've read of the android documentation, I thought that because I'm using the newer techniques that a ContentObserver would be created in the background for me, and I would just get automatic calls to the Loader. If there's any more information that would be helpful, I'd be glad to add it, or to upload the complete project somewhere. Additionally, I'm targeting KitKat (sdk version 19). Application Overview We have a ListActivity using the builtin ListView. The ListActivity gets data by using

What is the purpose of an Android projection map in a content provider?

自古美人都是妖i 提交于 2019-12-05 14:06:37
问题 I am looking at the Android notepad application sample code in <path_to_SDK>/samples/android-16/NotePad/src/com/example/android/notepad . I was wondering if anyone could explain to me why the following code is needed in NotepadProvider.java ? // Creates a new projection map instance. The map returns a column name // given a string. The two are usually equal. sNotesProjectionMap = new HashMap<String, String>(); // Maps the string "_ID" to the column name "_ID" sNotesProjectionMap.put(NotePad