Missing table in SQLite with specific version of DESIRE HD

Problems with WiFi, SQLite ,Bluetooth, WiMax, Proxies, etc...

Missing table in SQLite with specific version of DESIRE HD

Postby william104 » Wed Jan 12, 2011 3:05 pm

My application has a SQLite database in the asset folder. When the user launches my application, the database is created and the tables too.

This works fine with a lot of devices (Nexus One, Htc Magic, SGS, X10… and even Htc Desire HD v2.2). My application works with all versions of Android (tested on my device (1.6, 2.2, 2.2.1 Htc Magic) and on the emulator (v1,5 until v2.3).

I have just a problem with HTC DESIRE HD v2.2.1 1.72.405.3.

The logcat:

android.database.sqlite.SQLiteException: no such table: LISTE: , while compiling: select _id from LISTE at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2833) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2854) at android.app.ActivityThread.access$2300(ActivityThread.java:136) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2179) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:143) at android.app.ActivityThread.main(ActivityThread.java:5068) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:521) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) at dalvik.system.NativeStart.main(Native Method) Caused by: android.database.sqlite.SQLiteException: no such table: LISTE: , while compiling: select _id from LISTE at android.database.sqlite.SQLiteCompiledSql.native_compile(Native Method) at android.database.sqlite.SQLiteCompiledSql.compile(SQLiteCompiledSql.java:91) at android.database.sqlite.SQLiteCompiledSql.(SQLiteCompiledSql.java:64) at android.database.sqlite.SQLiteProgram.(SQLiteProgram.java:80) at android.database.sqlite.SQLiteQuery.(SQLiteQuery.java:46) at android.database.sqlite.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:53) at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1417) at android.database.sqlite.SQLiteDatabase.rawQuery(SQLiteDatabase.java:1387) ... 11 more


My application create the database but it doesn’t copy the tables of the file of the asset folder in data\data\packagename\databases\mydatabase.

My code:

Code: Select all
public void createDataBase() throws IOException{

boolean dbExist = checkDataBase();

if(dbExist){
  //do nothing - database already exist
}else{

  //By calling this method and empty database will be created into the default system path
           //of your application so we are gonna be able to overwrite that database with our database.
     this.getReadableDatabase();

     try {

   copyDataBase();

  } catch (IOException e) {

      throw new Error("Error copying database");

     }
}

}

private void copyDataBase() throws IOException{

//Open your local db as the input stream
InputStream myInput = myContext.getAssets().open(DB_NAME);

// Path to the just created empty db
String outFileName = DB_PATH + DB_NAME;

//Open the empty db as the output stream
OutputStream myOutput = new FileOutputStream(outFileName);

//transfer bytes from the inputfile to the outputfile
byte[] buffer = new byte[1024];
int length;
while ((length = myInput.read(buffer))!= -1){
  if (length > 0){
   myOutput.write(buffer, 0, length);
  }     }

//Close the streams
myOutput.flush();
myOutput.close();
myInput.close();

}


I think that the copydatabase function has a problem but I don't see.

This code works fine with all devices except the HTC DESIRE HD v2.2.1 1.72.405.3.

What problems might exist here for the HTC Desire with the given version above? How can this be remedied?

Thank you!!
william104
Freshman
Freshman
 
Posts: 2
Joined: Wed Jan 12, 2011 12:03 pm

Top

Re: Missing table in SQLite with specific version of DESIRE

Postby roccia80 » Wed Jan 12, 2011 9:47 pm

HI,

I have the same problem.

I usually test my application with virtual device (from 2.0 to 2.3), on Acer BeTouch E400 (Android 2.1), HTC Magic (Android 2.2.1), Samsung Galaxy Tab (Android 2.2) and they work fine.
I have received some bad comments about my applications from Htc Desire HD (android 2.2.1) users.

In my applications, i put database file in assets folder. Then, during its first use, application copies database file in the device filesystem, to the folder "/data/data/myapplicationpackagename/databases/". Then application executes query on this database.

The error stack trace in android application panel is always the same: "android.database.sqlite.SQLiteException: no such table: mydata, while compiling: SELECT…"

I don't understand where is the error in my application code and i don't try to emulate HTC Desire HD with Android SDK and Eclipse ADT plugin.

Can someone help us?

Thanks
Bye
roccia80
Once Poster
Once Poster
 
Posts: 1
Joined: Wed Jan 12, 2011 9:24 pm

Re: Missing table in SQLite with specific version of DESIRE

Postby william104 » Sat Jan 15, 2011 9:48 am

Hi,

I have found a solution thanks to a user of my application.
In the createdatabase function, it must be added:
public void createDataBase() throws IOException{

boolean dbExist = checkDataBase();
SQLiteDatabase db_Read = null;

if(dbExist){
//do nothing - database already exist
}else{

//By calling this method and empty database will be created into the default system path
//of your application so we are gonna be able to overwrite that database with our database.
db_Read = this.getReadableDatabase();
db_Read.close();

try {

copyDataBase();

} catch (IOException e) {

throw new Error("Error copying database");

}
}

}


I hope this will be able to help all people who have this problem.

Good Luck and long live Android

William
william104
Freshman
Freshman
 
Posts: 2
Joined: Wed Jan 12, 2011 12:03 pm

Re: Missing table in SQLite with specific version of DESIRE

Postby Dr_Wison » Sat Jan 15, 2011 10:36 am

Thanks William!

I have been preparing to script my populated database to get around this issue. I will try it immediately. Like you I have a user guinea pig that will test my app for me.

I will post back if it resolves the issue.

Cheers
Will
Dr_Wison
Freshman
Freshman
 
Posts: 2
Joined: Sat Jan 15, 2011 10:32 am

Re: Missing table in SQLite with specific version of DESIRE

Postby Dr_Wison » Sun Jan 16, 2011 3:46 pm

Hi William,
just to let you know one of my users tested it on the LeeDroid ROM (which had this issue) and your solution fixed the problem.

Cheers
Will
Dr_Wison
Freshman
Freshman
 
Posts: 2
Joined: Sat Jan 15, 2011 10:32 am

Re: Missing table in SQLite with specific version of DESIRE

Postby koelly » Wed Feb 23, 2011 12:26 pm

Hi Wiliam,

thank you so much for your solution.
I had the same problem on Nexus One with CM 7RC1,
but now it's solved :)

Thank you!
Bye, Koelly
koelly
Once Poster
Once Poster
 
Posts: 1
Joined: Mon Mar 15, 2010 8:27 pm

Top

Re: Missing table in SQLite with specific version of DESIRE

Postby ameya_dan » Tue Mar 01, 2011 9:51 am

Hi William ,
My app was also facing the same problem on Desire ... bt your soln worked for me :)
Thanks a lot.
ameya_dan
Once Poster
Once Poster
 
Posts: 1
Joined: Tue Mar 01, 2011 9:46 am

Re: Missing table in SQLite with specific version of DESIRE

Postby BigKev » Tue Apr 26, 2011 6:37 am

Hi - Thanks for this fix. I have Desire Z and this was crashing app on launch. Problem now is that SELECT gets data in Emulator but nothing returned on phone.
Any thoughts?
Thanks
BigKev
Once Poster
Once Poster
 
Posts: 1
Joined: Tue Apr 26, 2011 6:33 am

Re: Missing table in SQLite with specific version of DESIRE

Postby matinzk » Thu May 12, 2011 9:41 am

I have a similar problem also, where on createDatabase() method I get an error then Force Close.

I have put William's fix in my code but no luck!

The phone is an HTC Desire with Sense on it. Version is 2.2

Any ideas? this is getting very frustrating!

Thanks,
M.
matinzk
Freshman
Freshman
 
Posts: 2
Joined: Thu May 12, 2011 9:38 am

Re: Missing table in SQLite with specific version of DESIRE

Postby blundell » Sun May 15, 2011 2:52 am

Perfect :-)

Code: Select all
SQLiteDatabase db = getReadableDatabase();
db.close();


Did the job x
User avatar
blundell
Master Developer
Master Developer
 
Posts: 1610
Joined: Tue Nov 18, 2008 12:58 pm
Location: UK

Re: Missing table in SQLite with specific version of DESIRE

Postby matinzk » Sun May 15, 2011 9:48 am

Even that doesn't work for me!

Any ideas ?! :(

M.
matinzk
Freshman
Freshman
 
Posts: 2
Joined: Thu May 12, 2011 9:38 am

Re: Missing table in SQLite with specific version of DESIRE

Postby jebrkl » Mon Jun 13, 2011 2:55 pm

Thanks for posting this. I have had a few no such table errors reported in the Android market. I don't have a HTC Desire with this software version, but I am making the addition and hope these errors will go away.
jebrkl
Once Poster
Once Poster
 
Posts: 1
Joined: Mon Jun 13, 2011 2:45 pm

Re: Missing table in SQLite with specific version of DESIRE

Postby cinciampai » Fri Jul 08, 2011 4:19 pm

I had the same problem on my LG optimus one (P500) with android 2.3.3 (the same code works good on emulator 2.3.3, 2.2...), and the solution above works fine for me, thanks!!!! :D :D :D
cinciampai
Once Poster
Once Poster
 
Posts: 1
Joined: Fri Jul 08, 2011 4:14 pm

Re: Missing table in SQLite with specific version of DESIRE

Postby AndBzh » Mon Jul 18, 2011 9:31 pm

I've the same problem on HTC Inspire and HTC Desize Z.
I try the solution (to close the database), but this didn't solve my problem.
I've contacted HTC to show if they have a solution, but no answer for the moment.

Doesn't anyone have another idea for embedding a first version of a database and copying it on the phone for the first run and use it after ?
Find my app : Market
AndBzh
Freshman
Freshman
 
Posts: 7
Joined: Sat Nov 13, 2010 5:43 pm

Re: Missing table in SQLite with specific version of DESIRE

Postby vicentiu » Sat Jan 28, 2012 12:46 pm

william104 - thank you, that was the solution i was looking for.
I developed my application on samsung gio and I was very surprised that on Galaxy S Plus gave me that error.
vicentiu
Once Poster
Once Poster
 
Posts: 1
Joined: Sat Jan 28, 2012 12:39 pm

Top
Next

Return to Networking & Database Problems

Who is online

Users browsing this forum: No registered users and 3 guests