Friday, October 29, 2010

[android-developers] Re: android + sqllite : problem with accessing database

Oddly, you can't "pre-load" a database. You have to create it on the
phone and load it up from a flat file or some other source.

On Oct 29, 6:13 am, Mad Troll <trollheim.independ...@googlemail.com>
wrote:
> I created database in sql lite with commands:
> sqlite.exe
> CREATE TABLE "android_metadata" ("locale" TEXT DEFAULT 'en_US');
> INSERT INTO "android_metadata" VALUES ('en_US');
> CREATE TABLE "myTable" ("ID" int);
> INSERT INTO "myTable" VALUES ('1');
> .....................
> etc.
> i saved to file myDatabase.db
> and i'm trying open it through android.
> I open new project in eclipse
> i put my database in assets folder
> and i tried open my db using code:
>
> SQLiteDatabase checkDB = null;
>  String DB_PATH = "/data/data/my.andoid.app/databases/";
>  String DB_PATH = "myDatabase.db";
>
>         try{
>                 String myPath =DB_PATH + DB_NAME;
>                 checkDB = SQLiteDatabase.openDatabase(myPath, null,
> SQLiteDatabase.OPEN_READONLY);
>
>         }catch(SQLiteException e){
>                 return e.getMessage();
>         }
>
> And i can't open my database.
> Could anyone help me and point me what i'm doing wrong?
> regards

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate