SSLiteDatabase.openDatabase()

by Dale » Fri, 26 Feb 2010 11:24:08 GMT


Sponsored Links
 OK -- I'm frustrated with this...

I created a SQLite 3 database on using on my laptop.  I put the file
bigThaw.db in the assets folder in eclipse.  I then deployed the
application to my Droid phone.  It's a bluetooth app and cannot use
AVD.  I've move the file around to several locations but cannot seem
to get it to open.  The debugger keeps telling me "unable to open
database file".  I've move the file around in several places and
changed the path to the file but cannot get it to work.

Where should I putting the db file i created?  I tried putting it in
one of the packages that did not work. I also tried putting it in the
same area where the manifest is.


Here is the code:

public static void connect(){
    if(D) {
        Log.e(TAG, "+++ Before connect +++");
          }
        if( db == null  ){
            try {
                db = SQLiteDatabase.openDatabase("bigThaw.db",
Null,SQLiteDatabase.OPEN_READWRITE);
                 } catch(SQLException e){
                Log.e(TAG, "+++ Error Connecting +++");
                Log.e(TAG, e.getMessage());
                e.printStackTrace();
        }
        if( db != null && db.isOpen()){
                Log.e(TAG, "+++ DB is Open +++");

                try {
                        db.close();
                } catch ( SQLException e){
                        Log.e(TAG, "+++ Error Closing DB +++");
                }
        }
}

}

Thank you,

Dale

--



SSLiteDatabase.openDatabase()

by Mark Murphy » Fri, 26 Feb 2010 11:32:14 GMT


 


I have no idea what this means.

Bear in mind that you can't just plop a database in assets/ and expect
it to be usable. The material in assets/ is part of a digitally signed
APK and cannot be modified in place. *You* need to copy it to some
likely spot, either on the SD card somewhere, or in:

/data/data/the.package.from.your.manifest.goes.here/databases/

The definitive blog post on the topic appears to be:

 http://www.reigndesign.com/blog/using-your-own-sqlite-database-in-android-applications/ 

See also:

 http://stackoverflow.com/questions/2334461/open-sqlite-database-failed 

 http://stackoverflow.com/questions/2318784/the-sqlite-database-path 

 http://stackoverflow.com/questions/1894984/use-sqlite-database-from-android-app-resources 

 http://stackoverflow.com/questions/513084/how-to-ship-an-android-application-with-a-database 

-- 
Mark Murphy (a Commons Guy)
 http://commonsware.com  |  http://twitter.com/commonsguy 

Android Consulting/App Development:  http://commonsware.com/consulting 

--


Sponsored Links


SSLiteDatabase.openDatabase()

by Dale Hollon » Fri, 26 Feb 2010 12:40:41 GMT


 Great informaton.  I had no idea about the blogs or what the path to the sd
card was.

Thank you for the response.

Dale






I have no idea what this means.

Bear in mind that you can't just plop a database in assets/ and expect
it to be usable. The material in assets/ is part of a digitally signed
APK and cannot be modified in place. *You* need to copy it to some
likely spot, either on the SD card somewhere, or in:

/data/data/the.package.from.your.manifest.goes.here/databases/

The definitive blog post on the topic appears to be:

 http://www.reigndesign.com/blog/using-your-own-sqlite-database-in-android-applications/ 

See also:

 http://stackoverflow.com/questions/2334461/open-sqlite-database-failed 

 http://stackoverflow.com/questions/2318784/the-sqlite-database-path 

 http://stackoverflow.com/questions/1894984/use-sqlite-database-from-android-app-resources 

 http://stackoverflow.com/questions/513084/how-to-ship-an-android-application-with-a-database 

--
Mark Murphy (a Commons Guy)
 http://commonsware.com  |  http://twitter.com/commonsguy 

Android Consulting/App Development:  http://commonsware.com/consulting 


--



Other Threads

1. How to use jsr184 in android

Hi all,

Can any one help on this?  Does android support jsr184?  I have app
that is written using jsr184. How to convert this one so that it will
work on android phones?  ALso pls tell me whether i can use m3g format
in android device?  If i need to use some other api pls tell me about
that. And also send me some material link to learn the same

thanks in advance

--~--~---------~--~----~------------~-------~--~----~

2. Attempting to draw views to offscreen canvas

I am trying to make normal Android Views render offscreen so i can use
them as textures.

I can ofcourse call onDraw() on the views myself but how do i know
which Views i need to call this on. I really dont want to do this
every frame for all my views, only on the ones that has called
invalidate on themselves since the last frame.

I tried implementing a ViewParent but that does not work. I can not
call assignParent() on my views since that method is package private
so there is no way for me to get invalidation callbacks from my
children.

My next idea what to implement a ViewGroup and put the Views under
that then perhaps i can override invalidateChild() ? But that does not
work either since I can not override invalidateChild() in ViewGroup
since that mehod is final.

I then started looking at ViewTreeObserver. But there is no way to get
information on which Activities have been invalidated from any of the
callbacks in ViewTreeObserver.


Does anyone know how i can get information on what views needs to
redraw themselfes and how to get the dirty rect they supplied to
invalidate ?

--~--~---------~--~----~------------~-------~--~----~

3. Playing shoutcast mp3 stream in background crashes in 1.5

4. Analyzing audio in real time?

5. How can I know who started(binded) service?

6. Android emulator not closing properly

7. Receive SMS