android-contentprovider

Android SQLite database and app update

自闭症网瘾萝莉.ら 提交于 2019-11-28 17:33:50
问题 I have developed an android app and released version 1.0. The app contains SQLite local database with 5 tables. Now we planned to release version 2.0 also update the version 1.0 users. In version 2.0 we have included extra two tables with previous 5 table, so 7 tables now. Now my question is, The version 1.0 users all have some data in the local database, If he update to the version 2.0 the previous data will get lost? If it so. then what is the alternate method? 回答1: You should put all

Is it possible to access resources in another APK without using content providers?

核能气质少年 提交于 2019-11-28 16:54:26
I thought that it is impossible to access resources contained in other APK unless content providers are used. However, I stumbled upon an app called Better Keyboard. It uses skins, so I decided to download an example of a skin. An example skin really surprised me. It contains almost no code, declares only an activity and no content providers. Nontheless it contains resources and they are apparently somehow accessed from Better Keyboard app if the APK with the skin gets installed. So how is it done? I believe you're looking for Resources res = mPackageManager.getResourcesForApplication("org

Android: SQLite transactions when using ContentResolver

我怕爱的太早我们不能终老 提交于 2019-11-28 15:44:23
The goal: refresh database from XML data The process: Start transaction Delete all existing rows from the tables Per each main element of parsed XML insert row into main table and get PK Per each child of the main element insert record into 2nd table providing FK from the previous step Commit transaction Pretty standard stuff as far as db operations. The problem is that CRUD operations are not done within ContentProvider but rather using ContentResolver so the insert for example looks like resolver.insert(CONTENT_URI, contentValues) . The ContentResolver API doesn't seem to have anything

How do I use the Android SyncAdapter?

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-28 15:14:54
I try to understand the Android synchronization logic. What I don't understand is the file syncadapter.xml contained in the Android SDK sample project SampleSyncAdapter . If you downloaded the SDK samples it should be in the following folder: SDK/android-sdk-PLATFORM/samples/android-VERSION/SampleSyncAdapter/res/xml/syncadapter.xml I read, the authority of a content provider should be a string or a reference to a resource. What exactly is the content authority and where is com.android.contacts ? Here is the content of the file (w/o license information and comments, API level 16). <sync-adapter

Explicitly saving new messages to inbox

邮差的信 提交于 2019-11-28 14:08:21
Question regarding content://sms/inbox : 1) Is it advisable to explicitly store incoming messages to inbox? 2) What if an android device has a native messaging app and my messaging app was installed to it, and then I explicitly store incoming messages to inbox, will the messages duplicate? 3) Does android automatically store new messages to inbox regardless if there is a messaging application? Thanks. Regarding SMS, details vary depending on the Android version. Prior to KitKat, the SMS API was undocumented. With KitKat, the concept of a default SMS app was introduced, and the SMS API became

android: EXDATE format when adding a calendar event

泪湿孤枕 提交于 2019-11-28 12:23:41
Can someone explain how to use EXDATE when adding event to android calendar? The documentation is pretty unclear about the format in which the EXDATE should be put. I tried many formats, these are some of them: values.put(Events.EXDATE, "TZID=Europe/London:20130116T080000"); values.put(Events.EXDATE, "20130116T080000Z"); values.put(Events.EXDATE, "20130116T080000"); values.put(Events.EXDATE, "20130116"); but none of them works. Any idea how to make an event not appear on a particular date, if by the RRULE it should appear? The correct format is: values.put(Events.EXDATE, "20130116T080000Z");

Android - How can I pass data related to two tables to a the insert method of a Content Provider

随声附和 提交于 2019-11-28 11:47:35
I need to insert data related to an Order and its corresponding Detail . Without a ContentProvider I would do something like this: public boolean insertOrder(Order order, ArrayList<OrderDetail> items) { boolean wasSuccessful = false; ContentValues cvOrder = new ContentValues(); cvPedido.put(ORDER_CUSTOMER_ID, order.getCustomerId()); cvPedido.put(ORDER_CUSTOMER_NAME, order.getCustomerName()); String insertQuery = "INSERT INTO " + ORDER_DETAIL_TABLE + " VALUES (?,?)"; //... try { this.openWriteableDB(); SQLiteStatement statement = db.compileStatement(insertQuery); db.beginTransaction(); long

Android: call custom methods in a ContentProvider

萝らか妹 提交于 2019-11-28 10:55:58
I have a custom ContentProvider I use to store fixes obtained from the GPS into a SQLite database. This class overrides ContentProvider methods (delete, insert, query...), but notice I have also included a method to query the last fix. public class FixesContentProvider extends ContentProvider { @Override public int delete(...) { ... } ... @Override public Cursor query(...) { ... } public Cursor getLastFix(Uri uri) { ... } } It is pretty easy to query data from other services or activities by calling getContentResolver() . ContentResolver cR = getContentResolver(); Cursor fixes = cR.query

How can I get/set bookmarks per account on Android

邮差的信 提交于 2019-11-28 10:30:50
问题 Managing bookmarks using Android's default Browser, one can see that they are different kind of bookmarks. Local bookmarks, per (Google) account bookmarks. Getting all bookmarks (local and per-account) is quite straightforward. Here is how I proceed: public static List<Bookmark> getBookmarks(ContentResolver contentResolver) { String[] projection = new String[] { BookmarkColumns._ID, BookmarkColumns.TITLE, BookmarkColumns.URL, BookmarkColumns.VISITS, BookmarkColumns.DATE, BookmarkColumns

cursorboundexception whille displaying listview from content provider

流过昼夜 提交于 2019-11-28 10:22:48
问题 somebody pls get me out of this.I am trying to display a list from an sqlite database which worked absolutely fine but dont know what went wrong it showed cant find provider info.I fixed it and then when i am running the code with list_cursor.moveToFirst() it just shows the 1st item in list again and again which proves that it is fetching data....When I use list_cursor.moveToNext() it shows the following exception:PLS HELP ME 10-13 15:11:41.017 5337-5337/com.phase3.mascotnew E/AndroidRuntime: