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. suggestion about time interval selection

On the time selection GUI element it would be nice to hold the up or
down arrow for the minutes and instead of it going one digit at a
time, it would follow the following behavior:

Digits 1 thru 9 would be one at a time, when 10 was reached a
vibration feedback event would happen and then it would go by 5's or
10's. If you wanted 43, you would hold the button until 40 was reached
then lift your finger, and tap the up arrow 3 more times to reach 43.

-- 
.

2. Location problem

Hi!!

i am new to android and not being able to display current location on
map so can you provide me the code for
displaying Location with manifest.xml and main.xml...


please reply fast!!!!!
it nis urgent!!!!

--

3. ScrollView question

4. launching picasa from my app

5. Can't achieve focus under cascading framelayouts!

6. LocationListener sometimes not receiving updates from "network" provider

7. Unit Testing - Activity shutdown