android-contentprovider

Is it possible to use ContentProvider and direct data access to Database in Android? (multiple application case)

你。 提交于 2019-12-12 01:52:15
问题 I have a similar question as here: Is it possible to use ContentProvider and direct data access to Database in Android? but in my case I want the widget application to be a separate application. So I have a first Android application that is using a sqlite database using standard SQLiteOpenHelper. this helper is a singleton that is created in my Application onCreate. Works good. Now I want to make a second application -so a widget application- that needs to access the database as well. So I

Android union query

拈花ヽ惹草 提交于 2019-12-12 01:22:19
问题 I have the following problem: I have a table called planing it has the following fields: idplaning, month, year, shop, target, sales so the table will contain info like this (ignoring the idplaning): month year shop target sales ------------------------------------------- 1 2014 ShopName1 3534 122 2 2014 ShopName1 2323 111 ... 12 2014 ShopName1 7865 328 1 2014 ShopName2 4544 544 2 2014 ShopName2 5675 642 ... 12 2014 ShopName2 4623 323 ... 1 2015 ShopName1 3534 122 2 2015 ShopName1 2323 111 ..

ContentProvider or Service?

最后都变了- 提交于 2019-12-12 00:16:11
问题 I am writing an application that shows "Japanese Traditional Time" (JTT for short). There are several components (notification, widgets, application itself, alarms) which all use the same data - current JTT. My current version uses a single service that does all the calculation and uses a Handler to notify everyone about "ticking", mimicking ACTION_TIME_TICK . However with alarms I need to also have a way to translate "usual time" to JTT and vice versa. The calculations are quite CPU-heavy

Best way to access all the details of android contacts

99封情书 提交于 2019-12-11 23:22:34
问题 I am writing an application to sync contact details with my server. For this I need to query Contacts using content provider multiple times as all the data is not present in one table. For example by using contact id, I have to query separately to phone, email and address tables for each contact which I feel is not much efficient. It would be really helpful if someone could point me out ways to get all the contact details in a single query. Thanks in advance :) 回答1: If you have the

Optimise thousands of SQLite queries android

北战南征 提交于 2019-12-11 21:28:16
问题 I have this task where I need to query all details about every contact and back it up. The first 770 contacts take up 5-6 seconds to load while after 770 contacts, each contact takes more than a second to query all data. I understand that this is a complex query but that is just too slow. Is there any way to optimize this? Code // This contacts array typically contains more than a thousand items in it, even more contacts.forEach { val lookupKey = it.lookupKey queryContacts(lookupKey) } fun

your app(s) are using a content provider with an unsafe implementation of openfile :App is rejected from playstore

旧时模样 提交于 2019-12-11 18:49:06
问题 My app is being rejected due to your app(s) are using a content provider with an unsafe implementation of openfile. @Override public ParcelFileDescriptor openFile(Uri uri, String mode) throws FileNotFoundException { File privateFile = new File(uri.getPath()); ParcelFileDescriptor desc = ParcelFileDescriptor.open(privateFile, ParcelFileDescriptor.MODE_READ_ONLY); return desc; } <provider android:name="android.support.v4.content.FileProvider" android:authorities="${applicationId}.fileprovider"

How to get file path from the content uri for zip file?

这一生的挚爱 提交于 2019-12-11 17:14:14
问题 I am triggering an intent for selecting a zip file and in onActivityResult, it is providing me a content URI. For example :: (content://com.android.providers.downloads.documents/document/197). The file which is selected is from the download folder. Can any one explain, How to query the content resolver in order to get the file path? Thanks. Already tried code :- Cursor cursor = getActivity().getContentResolver() .query(contentUri, null, null, null, null); try { if (cursor != null && cursor

Is it possible to use ContentProvider and direct data access to Database in Android?

本秂侑毒 提交于 2019-12-11 15:13:51
问题 I have application that uses direct data access to it's Database. I have nothing to expose outside of it for other applications. As CommonsWare says somewhere on SO, "if you have nothing to expose - don't use ContentProvider". Now, I want to add widget to display a couple of strings from one of the tables, storing in Database. Should I refactor the direct access code to the ContentProvider pattern? Is there a way to use direct access to Database from widget? Is there a way to have both

Content Providers, Authority and URI matching

泄露秘密 提交于 2019-12-11 14:15:19
问题 I've been trying to work on a custom content provider and I have a few questions. How is the Android framework using Authority property? Why is it required to declare it in the manifest, shouldn't the class name be enough? Who/what process calls the getType() method in the ContentProvider implementation? What is the need of the urimatcher? Should it be used if the underlying database has only a handful of tables? 回答1: You are required to declare it in the manifest because data access

Filter contacts except groups of account type

廉价感情. 提交于 2019-12-11 14:04:13
问题 I need to build a contact picker which list all phone's contact except an account type of contact. I did follow this way : Example the account type I want to remove from the list is : group = "com.account.myaccount" First I query all the group id have the account type : public String[] getGroupIds(Context context, String group){ final Cursor groupCursor = context.getContentResolver().query( GroupWrap.CONTENT_URI, GroupWrap.PROJECTION, GroupWrap.SELECTION_GROUP_ID, new String[]{group}, null);