hey,
I am using the following code to obtain info from my db;
Now, i am packaging a database in my assets folder which have these columns in, however it did not used to. When my program starts , for now i am overwiting my assets folder database to the one that gets autocreated in ;
"/data/data/PACKAGE_NAME/databases/";
essentially, the new column is not getting added, so the database is not getting copied over. It sounds like a simple error but i cant for the life of me track it down. So i was wondering if the emulator cache's a copy of the DB or something? C.getColumnIndex keeps returning -1 for one of my columns that is 100% in my db in my assets folder.
any help would be awesome!!
thanks
------------------
(just for extra info, i copy the database when my program starts like this; I do i like this because its the only way i know to package your app with pre-existing data in it!)
)
I am using the following code to obtain info from my db;
int name1Idx = c.getColumnIndex("Name1");
int name2Idx = c.getColumnIndex("Name2");
int name2Idx = c.getColumnIndex("Name2");
Now, i am packaging a database in my assets folder which have these columns in, however it did not used to. When my program starts , for now i am overwiting my assets folder database to the one that gets autocreated in ;
"/data/data/PACKAGE_NAME/databases/";
essentially, the new column is not getting added, so the database is not getting copied over. It sounds like a simple error but i cant for the life of me track it down. So i was wondering if the emulator cache's a copy of the DB or something? C.getColumnIndex keeps returning -1 for one of my columns that is 100% in my db in my assets folder.
any help would be awesome!!
thanks
------------------
(just for extra info, i copy the database when my program starts like this; I do i like this because its the only way i know to package your app with pre-existing data in it!)
Code:
[LEFT]private void copyDataBase() throws IOException{[/LEFT]
[LEFT]//Open your local db as the input stream
InputStream myInput = myContext.getAssets().open(DB_NAME);[/LEFT]
[LEFT]// Path to the just created empty db
String outFileName = DB_PATH + DB_NAME;[/LEFT]
[LEFT]//Open the empty db as the output stream
OutputStream myOutput = new FileOutputStream(outFileName);[/LEFT]
[LEFT]//transfer bytes from the inputfile to the outputfile
byte[] buffer = new byte[1024];
int length;
while ((length = myInput.read(buffer))>0){
myOutput.write(buffer, 0, length);
}[/LEFT]
[LEFT]//Close the streams
myOutput.flush();
myOutput.close();
myInput.close();[/LEFT]
}
)