Android : Sqlite Open Helper Db Adapter Design

Jul 27, 2009

I am writing an app that has a single database file with 3 tables ( AudioTable, PeopleMap, ImageTable) and am looking at 2 design alternatives:

1. A -single- database adapter ( which uses a database helper class that extends SQLiteOpenHelper. The adapter class has separate methods for accessing and updating rows in each of the 3 tables. ie. insertAudio() insertPeople() insertImage()

2. 3 different database adapters for each table all using the same db file.. 1., 2., 3. Each adapter uses it's own db helper class (extending SQLiteOpenHelper)

While option 2 offers better encapsulation of the 3 classes (and corresponding data), I'm wondering if there couldbe a performance overhead or does the SQLiteOpenHelper implementation handle this without much overhead ?

Or is there some other way I can get better encapsulation with option 1. something similar to the way the Contacts Provider nicely allows for separate instances of Contacts.People, Contacts.Phones, Contacts.Settings, etc.

Android : Sqlite Open Helper db adapter design

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 :: Open Helper To Open Database And Get A Cursor To Pass To CursorAdapter

Jul 1, 2010

I have a ListActivity that uses a CursorAdapter to fill the rows in the view. I wrote a database helper class that gives me back results for common queries I make for my app, and it uses an SQLiteOpenHelper implementation I wrote to open the database. I use the open helper to open the database and get a cursor to pass to my CursorAdapter.

Here's a code snippet:


The problem I'm having, that I didn't have before I implemented the open helper (before I just opened the database directly without a helper), is when I click on an item, which takes me to another activity, and then go back to this activity. When it initializes everything is fine, and my list is populated fine, but when I go back from the activity that follows, the list is empty and in the LogCat I see "Invalid statement in fillWindow()".

It appears from a few post I've seen that the reason is, when I requery the cursor, the database is closed. But I'm not closing it! I'm scratching my head on this one.

View 2 Replies View Related

Android : VLC Remote - Does VLC Setup Helper Open To Establish A Connection With Phone

Aug 15, 2010

note: there are two versions of VLC Remote, I'm talking about this one:

Is VLC Setup Helper supposed to be open on the computer to establish a connection with my phone? When I'm playing a file in VLC, and open up the phone's app, it won't connect until I open up "VLC Setup Helper". It just seems a hassle to always remember to open up VLC Setup Helper all the time.

View 6 Replies View Related

Android :: ListActivity Design / Changing Content Of List Adapter

May 31, 2010

I would like to write a rather simple content application which displays a list of textual items (along with a small pic).I have a standard menu in which each menu item represents a different category of textual items (news, sports, leisure etc.).Pressing a menu item will display a list of textual items of this category.Now, having a separate ListActivity for each category seems like an overkill (or does it?)
Naturally, it makes much more sense to use one ListActivity and replace the data of its adapter when each category is loaded.My concern is when "back" is pressed. The adapter is loaded with items of the current category and now I need to display list of the previous category (and enable clicking on list items too)
Since I have only one activity - I thought of backup and load mechanism in onPause() and onResume() functions as well as making some distinction whether these function are invoked as a result of a "new" event (menu item selected) or by a "back" press.This seems very cumbersome for such a trivial usage.Am I missing something here?

View 1 Replies View Related

Android :: How To Use SQLite Database? (Create / Open)

Apr 18, 2010

I am trying to use

SQLiteDatabase.openDatabase( "/data/data/edwin11.myapp/databases/myapp.db", null, (SQLiteDatabase.CREATE_IF_NECESSARY | SQLiteDatabase.NO_LOCALIZED_COLLATORS));

To create/open a database instead of making use of the SQLiteOpenHelper (because I want to pass in the flag SQLiteDatabase.NO_LOCALIZED_COLLATORS. However, I am getting this exception for that line of code:

04-18 09:50:03.585: ERROR/Database(3471): sqlite3_open_v2("/data/data/edwin11.myapp/databases/myapp.db", &handle, 6, NULL) failed
04-18 09:50:03.665: ERROR/AndroidRuntime(3471): java.lang.RuntimeException: An error occured while executing doInBackground()
04-18 09:50:03.665: ERROR/AndroidRuntime(3471): at android.os.AsyncTask$3.done(
04-18 09:50:03.665: ERROR/AndroidRuntime(3471): at java.util.concurrent.FutureTask$Sync.innerSetException(
04-18 09:50:03.665: ERROR/AndroidRuntime(3471): at java.util.concurrent.FutureTask$Sync.innerRun(
04-18 09:50:03.665: ERROR/AndroidRuntime(3471): at
04-18 09:50:03.665: ERROR/AndroidRuntime(3471): at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(
04-18 09:50:03.665: ERROR/AndroidRuntime(3471): at java.util.concurrent.ThreadPoolExecutor$
04-18 09:50:03.665: ERROR/AndroidRuntime(3471): at
04-18 09:50:03.665: ERROR/AndroidRuntime(3471): Caused by: android.database.sqlite.SQLiteException: unable to open database file
04-18 09:50:03.665: ERROR/AndroidRuntime(3471): at android.database.sqlite.SQLiteDatabase.dbopen(Native Method)
04-18 09:50:03.665: ERROR/AndroidRuntime(3471): at android.database.sqlite.SQLiteDatabase.<init>(
04-18 09:50:03.665: ERROR/AndroidRuntime(3471): at android.database.sqlite.SQLiteDatabase.openDatabase(

Doing some testing just before that line of code (using File.isExists) shows that the file /data/data/edwin11.myapp/databases/myapp.db does not exist. Would that be the cause of the error? (Or am I just using SQLiteDatabase.openDatabase the wrong way?) Would it help if I create the file beforehand? (Shouldn't that be taken care of by the SQLiteDatabase.CREATE_IF_NECESSARY flag that I passed in?) If creating the file manually is the way to go, is it just an empty file, or do I have to write something to it?

View 1 Replies View Related

Android :: Open PDF / Xml Which Stored In A SQLite File?

Jul 5, 2010

How can I open them which have already stored in SQLite?

View 2 Replies View Related

Android :: How To Close And Re-open Sqlite Database

Jun 23, 2010

In my app, I'm supporting the backup and restoration of the Sqlite db file. I need to close and re-open my database connection after the restore. How can I do this?

View 2 Replies View Related

Android :: Android: SQLite One-to-many Design

Feb 5, 2010

Anyone has good advise on how to implement one-to-many mapping for SQLite using ContentProvider? If you look at Uri ContentProvider#insert(Uri, ContentValues) you can see that it has ContentValues param that contains data to insert. The problem is that in its current implementation ContentValues does not support put(String, Object) method and class is final so I cannot extend it. Why it is a problem? Here comes my design:

I have 2 tables which are in one-to-many relationship. To represent these in code I have 2 model objects. 1st represents the main record and has a field that is a list of 2nd object instances. Now I have a helper method in the model object #1 which returns ContentValues generated off the current object. It's trivial to populate a primitive fields with ContentValues#put overloaded methods but I'm out of luck for the list. So currently since my 2nd table row is just a single String value I generate a comma delimited String which then I reparse to String[] inside ContentProvider#insert. That feels yucky, so maybe someone can hint how it can be done in cleaner fashion.

Here's some code. First from the model class:


and here's slimmed down version of ContentProvider#insert method


View 2 Replies View Related

Android :: Open File Which Is Stored In SQLite As Blob

Jul 19, 2010

As the title, I create a ByteArray to store the file in blob like this:byte[] red_buf = myCursor.getBlob(1);
But I don't know what's the next step to open the file.

View 1 Replies View Related

Android :: Open File Stored In SQLite As Blob

Jul 19, 2010

As the title, I create a ByteArray to store the file in blob like this: byte[] red_buf = myCursor.getBlob(1);And I wanna use FileOutputStream to open.But I don't know how to do. Can anyone give me a example or website please?

View 1 Replies View Related

Android :: Create A Helper Class To Display Toasts In App?

Dec 21, 2009

I am trying to create a Helper class to display Toasts in my android app, as follows.


My code is based on the example at:

My problem is, when I try to inflate the view, I can't call findViewById without the View from the activity I am calling toastAlert in. Is there a way I can access that view?

View 2 Replies View Related

Android :: GUI Design - Mockup Design Tool For Android Application

Nov 23, 2010

I am going to develop an Android Application but before developing it i needs to have MockUp for the Android Application,so is there any way to design MockUp/GUI Design tool for the Android Application?

I know about DroidDraw tool , but i think it is not the exact way to prepare Mockup for the android application.

I have already referred this SO Question , but overthere i just found all the tools for the I-Phone only. So please feel free to share with me if you have/found any !

View 3 Replies View Related

Android :: Way To Open And Edit Word File In Droid / App Exist Does It Has An Open API?

Jun 30, 2010

Is there a way to open and edit word file in android and if this application exist does it has an open API?

View 1 Replies View Related

Android :: Finalizing Cursor Android.database.sqlite.SQLite­Cursor

May 6, 2009

I am seeing the exception in 'adb logcat'.But I don't know if it is caused by my application or android platform.Can you please give me any idea how to troubleshoot this exception?

View 3 Replies View Related

Android :: Looking For A Design Tip / Advice / Doc

Aug 2, 2010

I'm kind of new to android development.I have read from many sources that findViewById() is a "costly" operation. I'm making an application that deals with 5 TextViews to provide different kinds of information (distance, duration, title, description, etc) from a database. I'm using listeners to catch touch/click events and feedbacks a handler. The main function of the handler is to received a "position" in the Cursor where the new information needs to be displayed. I mentioned earlier that findViewById() is a "costly" operation. So, I don't call this method in the handler. Doing so, it will retrieve every time the Views when user touchs/clicks some widget. Is it right to populate the Activity with private members of the Views/Layout it displays? I mean, I don't like it. I don't know why, but seems that I'm populating too much the activity. I'm aware of the android:onClick xml attribute, but in my case I also use long click listeners. So, a piece of onCreate() looks like: And all of those are private members, wihout mention the "cursor.getColumnIndex()" for each. I thought on implementing Handler.Callback and set on the Hanlder.Callback constructor implementer a View array or a View list or something, but I also need this objects later to set other listeners and setups. Is this right? I cannot think another way, as I need the reference to the object, and also the Cursor reference that the handler will move to the "position" provided and update the correspondent View. I will really appreciate either an advice or a useful link/info/doc to read in what concern in this kind of designs. What I do not like is that It looks like imperative programming filling the Activity with "global" variables.

View 6 Replies View Related

Android :: APN Design - Access Pointer - MMS

May 13, 2009

in Android code, It is a very strange concept to define the APN type (APN_TYPE_MMS). The reason are: 1) APN only is an access pointer, it haven't any special attribute for MMS or other things. 2) Only Application care the APN name, since different APN will provide different service from operator. for example, operation may provide Email/MMS/GPS/.... service on different APN. 3) Android only define one type APN_TYPE_MMS, this will limit other top application usage. Any one can answer me why Android design this way? If google have strong reason for such design, I hope add other user defined type like APN_TYPE_USER1 APN_TYPE_USER2 then top application can set his property to use its APN other than APN_TYPE_MMS

View 2 Replies View Related

Android :: How To Design A Floating Keyboard

Oct 13, 2010

I am a developer and recently completed the implementation of my keyboard MessagEase. It's available on the Market (with its very- different features, making it quite unlike QWERTY).

This keyboard works fine as a replacement of the standard keyboard on an Android Phone. But for a An Android Tablet, it would work best if it's implemented as a floating, movable keyboard.

(the footprint of this keyboard is mostly dependable on the size of a human's finger; it remains the same even if the tablet's display is much larger than a phone's. Therefore it'll take a relatively smaller area on a tablet.)

If I use the current SDK hooks, it will have to take a significant portion of the screen, defeating the purpose.

View 2 Replies View Related

Android :: Activity Design Advice

Mar 3, 2010

I have a service running that grabs the users attention with a notification. What i would like to happen when the user clicks on the notification is for it to launch a dialog box. The "proper" thing to do is to launch an activity in this way, so is there a way to get an activity to launch with out filling the screen? So it looks like a dialog box?

View 5 Replies View Related

Android :: Launcher Icon Design

Sep 1, 2010

I'm more than happy coding apps.I am, however, rubbish at icon design.I'm sure I'm not the only one for whom this is a problem and yet all android devs need to create a launcher icon.Does anyone have any good tips on knocking up simple but effective launcher icons?

View 5 Replies View Related

Android :: Using 3d Packages For Icon Design

Nov 3, 2010

if this is a silly question, am sorry about that. I was wondering if its possible to design android icons using a 3d modelling package like blender? i know i have to stick to the guidelines documented already, but was just wondering if anyone had come across or done something similar? Its that little part of the icons(launchers) being able to have a slight perspective and looking through the requirements to design icons it seems i might be a lot faster using a 3d modelling package and then following part of the icons template guide(based from my requirement though!).

View 2 Replies View Related

Android :: Use IMF To Design Soft A Keyboard?

Aug 29, 2010

how to use the IMF to design a soft keyboard. Please point me to some resources that will help me understand how to do it from the ground up. Something other than the SDK sample

View 4 Replies View Related

Android :: Layout Design For HTC Desire

Sep 18, 2010

I designed an app for htc desire.The background image used for the app looks good in ecipse layout, when installed in phone it is stretched.

View 2 Replies View Related

Android :: UI Design For Board Game

Jan 5, 2010

I need to design a board UI using android platform. I was planning to take one image as board and moving the required images over the board. How do I achieve the same? I need to find the coordinates for image and need to move the required images to specifies coordinates. Is there any andorid API for this?

View 2 Replies View Related

Android :: Example / Code To Set Page For App Design?

Oct 8, 2009

Is anyone aware of an example or sample code that shows how to make a settings page (like what you get from hitting settings)? Many apps seem to have them but I'm not sure what type of list they are using.

View 4 Replies View Related

Android : Ddalvik Performance For API Design

Oct 7, 2010

Taking into account JIT and non-JIT devices, what would be most efficient on Android for returning multiple values from functions: an array like this: Code...

View 6 Replies View Related

HTC Hero :: Apps Open Without I Do Open Them In Task Manager

Jan 10, 2010

I open task manager i find no apps running i leave it for 1 min for example and i reopen it, i find some apps running without i run them such as MAIL, Touch input, why do they open

View 1 Replies View Related

Android :: Need Source / Links To Implements A Design?

Jul 21, 2010

Referring Can any body provide source/links which implements such a design?

View 2 Replies View Related

Android :: Database Access Design Approach

Aug 30, 2010

I have a general Android design question around data access. I have a number of activities in my application that need to access a SQLite database. In order to wrap up all data access logic in one place I have created a DatbaseHandler class that takes care of all data access logic. This class takes care of building up where clauses, calling the database and interrogating the resulting cursor to retrieve the query results and return them to the caller. The purpose of this class is to wrap all data access code in one place so that it can be easily managed and maintained as opposed to having data access logic scattered across all activities. Each activity that needs access to the database creates an instance of this DatabaseHandler class and passes it a reference of android.content.Context. The DatabaseHandler class then uses this Context object to call an underlying content provider as follows context_i.getContentResolver().query(...).

My data access logic (cursor handling logic to be specific) is not in the activity and so I cannot manage the cursors life cycle, therefore there is likely to be memory leaks.

My questions are as follows -

How can I (if its even possible) manage the cursors life cycle from outside an Activity? Should each activity even be creating an instance of this data handler class and passing an instance of Context to it? Perhaps my design approach is wrong and I should expose these data access functions as static methods that take an instance of the calling activity as a parameter. That way I could perform managed queries and let the activity take care of managing the cursors life cycle?

View 1 Replies View Related

Android :: App Design For Multiple Data Connections

Oct 18, 2010

I am working on developing an application that requires me to establish multiple client-server based connections. Connection can be of two types where the Android device can be a server or a client. I can have up to 6 - 8 connections. Once the connections are set-up they need to be running in the background and are not typically affected by UI actions.Since each connection can be blocking, I am wondering what is a good away to design this app. Should I have two services for handling the server and client connections? Each service could have a "connection manager" that can spawn new threads when necessary. Or does creating two services even help? I presume spawning new processed would not be good as they will be expensive. Is this correct? I would appreciate any suggestions. Also, if this use case is not typical please let me know if you need more information to make any recommendation.

View 2 Replies View Related

Copyrights 2005-15, All rights reserved