Android :: SQLite & Concurrent Access Best Practices

May 8, 2010

I have an application with several tables, each being updated by AsyncTask fired by different Activities and used by UI with SimpleCursorAdapter. Though i am not developping a game, I would like to avoid to interrupt the user as mush as possible. Has SQLite is not multiaccess proof, what is the best way of handling such situation?

- I consider adding lock from each DB open and to each close sequence but this seems quite subject to bugs - The solution i am using now is that each DB access (read/write) is done in UI thread (when AsyncTask completes, DB write is done typically in onPostExecute), but that means user is blocked for several seconds during the DB write.

Is there any better solution for that? Should i use a ContentProvider? when i read "Content providers store and retrieve data and make it accessible to all applications", this does not seems to be what i need. Any idea?

Android :: SQLite & concurrent access best practices


Android :: Concurrent Modification Exceptio­n In SQLite

Oct 19, 2010

I'm doing some stress testing of my SQLite database using the testing monkey and I got the following exception, which appears to be from inside SQLite. My app has many threads accessing the database but all of them do so in locking mode so I don't think this exception is my fault. Any opinions on whether I should worry about this exception or if it's just an artifact of the extremely fast monkey keyboard access? Code...

View 9 Replies View Related

Android :: Best Practices For SQLite DB And Content Provider

Nov 12, 2009

My Android app is reading and writing to a local SQLite DB from a few different Activities and a Service. Pretty standard. But I'm not happy with the way I've got all the DB details stored as constants that I then use anywhere I access the DB. I've been advised to wrap the DB in a ContentProvider. Sounds good to me. While I'm refactoring my code, I figured I'd ask: What are your best practices for local DB data storage in Android?

Where and how do you store "CREATE TABLE" statements, column names, other SQL? Would you mind sharing a list of the classes you instantiate and what goes into each (ContentProvider, DatabaseProvider, DatabaseHelper...)? How do you coordinate the structure of your local Android DB with a server-side DB available through a REST interface? I realize I'm getting at the perennial "where's the Android object-relation-mapping framework?" question. For now, I'm mainly curious to hear how you structure your Android apps with what's available in the standard SDK.

View 4 Replies View Related

Getting ANR In Concurrent DB Access

Mar 14, 2014

I have used content resolver in my project and override the applyBatch() for writting data into the database :

@Override
public ContentProviderResult[] applyBatch(ArrayList<ContentProviderOperation> operations)
throws OperationApplicationException {
final Context context = getContext();
final SQLiteDatabase db = getDatabase(context);
db.beginTransaction();

[Code]...

If there is any writing operation to the database, applyBatch() method get called and in same time if I will make query from database(using CursorLoader), ANR comes and the following exception will also comes :

W/SQLiteConnectionPool(18025): The connection pool for database '+data+data+com.abc.xyz+databases+XYZ' has been unable to grant a connection to thread 8073 (pool-17-thread-3) with flags 0x2 for 64.105 seconds.

W/SQLiteConnectionPool(18025): Connections: 0 active, 1 idle, 0 available.

The above issue will not come if I remove the methode db.beginTrasaction() and db.endTrasaction() from applyBatch(). But in that case reading/writing time becomes large. I have used methods db.beginTrasaction() and db.endTrasaction() which reduces database access time to ten times.

Is there any approach, so that SQLite DataBse response quickly and there is no ANR ?

View 1 Replies View Related

Android :: How To Access Data From Sqlite?

Sep 15, 2010

How to access existing data from sqlite and how to implement the data in list view in android.

View 1 Replies View Related

Android :: Access A Sqlite Database That Is Not Own By My Application

Jan 31, 2010

I'm searching information about how i can access a specific database that to not belong to me, and that is store in /data/data/com.... directory is it possible without root access? it it possible with root access, and how?

View 3 Replies View Related

Android :: Prevent Access To SQLite Database

Oct 18, 2010

I use a sqlite database in my project. The stored data in it must not be available for the user to edit. As I've read here I saw that if you have root access you can alter sqlite database. The only solution would be to encrypt database content, but this would be time consuming for device. Any solution to prevent access to database ?

View 1 Replies View Related

Android : Way To Access An Sqlite Database In Droid?

Dec 23, 2009

So far we have developed apps in android that create database on runtime. We like to know how can we access a pre-built or existing database/sqlite file in our android app?

View 1 Replies View Related

Android :: Possible To Access Sqlite File That Is Bundled With Application?

Mar 11, 2010

I have a database that I have already populated locally. I want to bundle it with my applications and access it at runtime (never want to re-write it anywhere, nor write to the database, simply read). What is the path of a file that I have added to the bundle? And, can i use that path with a SQLiteDatabase.openDatabase ?

View 1 Replies View Related

Android :: Can I Download An SQLite Db On / Sdcard And Access It From Droid App

Jun 28, 2009

I already found out that there is no way to bundle files in an .apk and have them on /sdcard, the best option so far being to download the large files upon first run. I came accross a tutorial saying how to bundle an sqlite db with the apk and then copy it so that it can be accessed with SQLiteDatabase (thus doubling the space needed, and not using /sdcard at all).

http://developer.android.com/guide/topics/data/data-storage.html#db says all databases MUST be in /data/data/package_name/databases.

Is that really so? Is there a way to trick the framework into opening a database that is placed on the /sdcard partition? Is there a way to use another SQLite java wrapper/framework to access such databases?

If the answer to the above is 'No', what other options do I have? My data is very well represented in a relational model, but is just too big, plus, I want to be able to update it without the need to reinstall/upgrade the entire app.

View 2 Replies View Related

Android : Database Adapter Design / Want To Access SQLite DB

Oct 16, 2010

I'm developing an Android application with a database. That database will have more than three tables. Now I'm working on a class called DBAdapter to access the SQLite Database. DBAdpater will have five methods for every table on database (insertEntry, removeEntry, getAllEntries, getEntry and updateEntry). So, if I have five table, DBApadter will have more than twenty-five methods. I think is so huge. How may DBAdapter classes should be?

View 1 Replies View Related

Android :: Path For Droid Database Files On Ubuntu To Access With SQLite Browser?

Aug 13, 2010

I am trying to find the path for the android database files on Ubuntu 10.4, because I want to access with SQLite Browser. Someone can tell?

View 2 Replies View Related

How To Access Non-default Table Of Sqlite Database

Nov 14, 2011

i'm trying to access (read & write) from non-default (example 2nd table) table of a sqlite database which i created using sqlite database browser. but somehow, i cant seems to find the way to access it.

Code:
public class DatabaseHelper extends SQLiteOpenHelper {
private static String DB_PATH = "/data/data/com.sg/databases/";
private static String DB_NAME = "TestDatabase";
private SQLiteDatabase myDatabase;
[code]...

select data method works, but i can only select from table 1 and not table 2

View 4 Replies View Related

Android :: Bluetooth Concurrent Connections

Sep 14, 2010

For the buzzer round, I was thinking of writing 2 app for android (we have a few handsets), one for the quiz master and the other for the contestants.The contestants will be connected to the quiz master through bluetooth.After reading the question, the quiz-master clicks a button in his/her app, the button in the contestant apps will be enabled for X seconds. As soon as a contestant clicks his/her button, the quiz master's app will flash the name of that contestant.Is it even possible to have multiple connections and accept concurrent (or multiplexed) messages from them in bluetooth (something similar to select() in unix/c)?If possible, where should I look for any examples? What kind of problems will I face trying to develop this (I know reliability is an issue here) and how to avoid them?

View 2 Replies View Related

Android :: Java.util.concurrent.ConcurrentLinkedQueue

Apr 14, 2010

I want to use ConcurrentLinkedQueue in an android application, have written the code, but now I'm getting an error when the project builds:

Conversion to Dalvik format failed with error 2

I'm using Eclipse with the lastest version of the ADT plugin.

View 1 Replies View Related

Android :: Develop An Application Pluging / That Could Access Application Sqlite

Nov 15, 2010

I want to add a big feature to an application i am developping, but as this feature interest few people and is quite independant from the main part, I would like to put that in a seperate "plugin" application.Does anyone knows any design patterns, snippets, "reference" examples about such design?In particular that separate plugin application should be able to access some tables in the main application DB. Is it possible to do that without broadcast receiver? - the main application uses a TabActivity: is it possible that a the tabactivity instanciates an Intent Activity that is part of the plugin? - does the plugin can access main application preferences (not sure this would be necessary, but better to anticipate the question!) is it possible from the plugin to access main applications ressources?At least the 2 first points are mandatory for me.

View 4 Replies View Related

Android :: AsyncTask : Java.util.concurrent.RejectedExecutionException

Apr 7, 2010

I'm trying to launch a lot of remote connection retrieve picture on a server. To do this, I use AsyncTask.

This pics are displayed in a listview using adapter.

If I implement this in my adapter, images are retrieved but the display is bad (problem with index or something like that).

If I try to retrieve image when I build my object list (contained in my listview), I get the exception 04-07 13:35:57.744: ERROR/AndroidRuntime(4132):

CODE:.................

What is this exception ? Why I can launch multiple asynctask in my listview (giving to me a bad result) and not in a simple object without having this issue ?

View 6 Replies View Related

Android :: Multiple Concurrent Versions Of Same App / Filtered By Sdk Version?

Jul 30, 2010

I have an app on Android Market right now with a minSdkVersion corresponding to Android 1.6. I'd like to make an update that is only visible to users of Android 2.2 and higher (there is a good reason for this, which I will explain below). So I have two questions:
- First, if I publish an update with a higher minSdkVersion than the one it replaces, will existing users still be able to see and download the old version if their device is not >= that minSdkVersion? - Secondly, if so, would it be possible to publish updates to that older version branch? Or would it become a fossil relic, but at least always there for downlevel users? Now for the background. My apps use a large amount of resource files-- about 15MB for the Lite version, and about 55 for the Full version. Prior to Android 2.2, it was not possible to install an app on the SD card, so my solution to this was to have the app contain the bare essentials, and simply download the other resources from my web servers at first-run. However, this means that I must maintain external infrastructure, and it's also a bad experience for users who must download the app, then start another download sequence (I already have had several complaints about this in my user comments). What I would like to do is to keep the app as it is for users with Android OS < 2.2. I'd like to publish an update that is only visible to users with Android OS >= 2.2 which packages everything into the app and allows it to be stored on the SD card. And I'd like to be able to perform maintenance on both versions as needed. Why can't I just do the update as described above to a single branch of the app? Because it would mean that users with Android OS < 2.2 would have to download a massive application to their internal memory, which could be a deal-breaker for devices with only 128MB or 256MB, which is shared with the OS. Since I already have paying customers, I don't think I can ethically create an update that would potentially consume most of a user's internal memory, when the version they purchased was only a couple MB.

View 9 Replies View Related

Android :: CurrentTimeMillis Doesn't Match On Two Concurrent Emulators

Mar 10, 2010

I am testing my multiplayer game by running several instances of the emulator (which is, sadly, extremely slow and dis-satisfying). I depend on a little trick using currentTimeMillis() to keep a synchronized clock between the players (but NOT the absolute value of currentTimeMillis() since no two phones are probably set exactly the same)Anyway, I *do* naively assume that two emulators, running on the same PC would return near identical values for calls to currentTimeMillis(), and what I find is that they start off the same, but pull rapidly apart.Which makes me think the underlying implementation of currentTimeMillis() in the emulator is not at all based on the host PC's calendar, and rquires the emulator to get enough Windows compute cycles to be anything close to accurate. (and one emulator is always running at a lower priority to the other, depending on which one is on top)

If this is just an artifact of the emulator, then I can deal with it, but if it implies I have a fundamental misunderstanding of currentTimeMillis(), then that would be something i need to deal with. Part two of the question is: any way I can speed up the emulator? When I run two, are they sharing one of my cores? Can I split them onto separate cores?

View 10 Replies View Related

Android :: Overlay Concurrent Modification Exceptio­n Continued

Aug 27, 2009

This post is in addition to: http://groups.google.com/group/android-developers/browse_thread/threa. I have exactly the same problem and Doug pinpointed what's probably the issue in my case exactly: So here's the deal: I have a Vector containing traffic messages (received from a server via UDP in an own thread). Each time a message is received, I create a new overlay object and populate it with the traffic messages: Code...

View 4 Replies View Related

General :: How To Increase Concurrent HTTP Connections

Mar 3, 2013

My company is importing some Android-based TV boxes from China, and we're experiencing a strange bug with some apps we are developing to run on them. I'm trying to find a specific solution that I can tell them to implement in a firmware upgrade, but I am not sure where to look.

In some apps (especially Adobe AIR-based ones), there seems to be a limit to concurrent HTTP requests to a web server. On an earlier ICS 4.0.4 firmware for these devices, this did not cause any problems. But they recently released a JB 4.1.1 firmware, and this problem occurs.

Let's say an app requests 20 items by HTTP from a web server (XML files, PNG or JPG images). What will happen is about 2/3 of these will be sent back, and the rest just remains blank, as if in a perpetual waiting status.

Looking at the web server's logs, there is no requests at all for these missing items.

And, it's totally random. If you re-launch the app, the missing items will be different ones.

So, I am guessing the app can only request so many things at the same time. Any system property that could be adjusted to solve this?

BTW I am unable to replicate this bug on any other device. The TV boxes in question are based on Rockchip 3066 SoC's

View 5 Replies View Related

Android :: Best Practices In App UI Navigation

Jun 2, 2010

I am trying to learn how to do stuff in Android, and I'm not sure of the best way to build the interface.I've been working on porting an iPhone app, which uses navigation controllers and table views for looking at the different sections: basically, someone touches a cell in the table, which drills down to another table. when they touch a cell on that table it drills down to a webview that displays the information.I want to do something similar for the android app, but I don't know how, or if there is a better way native to Android. I've figured out how to use the webview to my purposes, but moving forward and backward in the table tree is unclear.

View 3 Replies View Related

Android :: Using MediaPlayer Best Practices

Nov 3, 2009

What is the best way to use the MediaPlayer when needed multiple times?

Reuse the instantiated MediaPlayer throughout the session? Or constantly stop() release() and instantiate a new MediaPlayer() ?

If I reuse I'm afraid the player could be in a bad state? What about performance wise? what's better? reuse or renew?

This is for using as a music player so one audio be present at one given time...

View 4 Replies View Related

Android :: Best Practices For Library With UI Component

Jun 26, 2009

My company is in the process of evaluating if we can add support for Android to our product. I am currently working on porting our existing J2ME library to the Android framework and I have a question regarding our UI component. Right now, we have a custom menu that we allow our developers to bring up on the device. On J2ME, we simply have a single call that the developer makes to enter into the menu and then we handle the rest. On Android, it seems the best way to handle this is an Activity. But I have a few questions regarding this approach including is the really the best way to do something like this? Second, if it is, if there are multiple applications on the device that are using our library, are there going to be conflicts with them all having the same Activity embedded in them? Is it possible to create an Actvity at runtime and use it directly? Would there be any side effects of going about it this way?

View 2 Replies View Related

Android : Best Practices To Be Followed When Designing Database?

Aug 30, 2010

I have to create a number of tables for caching some amount of textual data, obtained by reading XMLs. These tables need to be created only once - on the initial run of the application. The data in the tables should be cleared after fixed time period. There should be a class exposed to other classes that would allow CRUD operations on this database. Googling found me some links to tutorials for creating databases and Data Access logic.

I have some questions, please help:

How many DataBaseHelper(DBAdapter) classes should I have, I am guessing only one? Is it okay to have all the SQL DDL and DML statements, DB name, Table Names as static strings of this class?
How do I ensure that the tables are created only once?
Is it possible to clear the DataBase after a fixed time interval?
Are there any best practices to be followed when designing the database?
The data in the database is to be displayed in Lists. I have data in ArrayLists(created when parsing XML) as well as Database(after these lists are persisted). What adapter should I use to back the list up? Should I use ListAdapter or CursorAdapter?

View 2 Replies View Related

Android :: Any Best Practices For Starting / Handling Activities

Oct 23, 2010

Understanding how to declare activities in the manifest file, how to set the appropriate flags when starting them through intents, is quite challenging in all but the default cases. The combination of all these settings and flags is daunting. I've been developing for Android for over a year now, have read the application fundamentals and the reference guide for 'Intent' quite a few times and still I don't have a good grasp of which manifest settings or intent-flags should be used for starting activities in many situations (workflows). Is there some source/document that can explain certain work-flows (ways of navigation through activities and tasks), that shows examples of how to configure and start activities?

View 4 Replies View Related

Android :: Good Practices For Building Web Application

Sep 10, 2010

can you advice me a book or something else containing good practices about how to build/structure a web application in a way that will be easy to extend it with an Android/iPhone version later.I am currently trying to get into Django so it will be nice if the practices are related to it.

View 1 Replies View Related

Android :: Best Practices To Integrate Tips In Application

Apr 22, 2010

What are the best practices people have used to integrate help/tips in their application? One way I can think of is having html snippets in resources or assets - perhaps as html files - maybe as formatted strings. However, I think it would break down once an html file linked to another html file or an image or icon. I'm sure some of you have apps that are so wonderfully intuitive that they don't need any help. And I admire that. But I'm not making that assumption for my app.

View 6 Replies View Related

Android :: What Are Application Update Feedback And Best Practices?

May 20, 2009

I've published an Android applications on the Android market and now have an update to do. I want to know if any of you have already done that, and what experience can you share about it:

- How to manage version conflicts?
- What to do with databases?
- Can you make appear a message with "what's new" if it's an update, but nothing it's a new installation?
- Should you backup old data before updating, and how?
- Did you run into any trouble and how did you solve it?
- Can update be partial (like, just a patch)?

View 1 Replies View Related

Android :: Help A Newbie Learn Eclipse / Debugging Best Practices

Jul 25, 2010

I am a newbie to Android and the Eclipse development environment and would like some advice on best practices for debugging my apps when they throw a Force Close.I have researched ADB, however, I can not get this to interact with my phone even though I have explicitly turned debug mode to true on my test handset.Obviously Android comes with a LOG method which I have seen utilized in many example apps, can someone please explain how to review these logs quickly and how to setup logging appropriately to determine the cause of a Force Close (always occurs when I push the Home button).Any advice on debugging effectively in Eclipse would be much appreciated!

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved