从我在资产文件夹中的sqllite数据库中,我为谷歌地图加载标记的纬度和经度。在运行时,活动力因以下错误日志而关闭。
09-11 13:57:33.187: W/System.err(6560): android.database.sqlite.SQLiteException: no such table: gps: , while compiling: select * FROM gps WHERE type="Agence"
09-11 13:57:33.296: W/System.err(6560): android.database.sqlite.SQLitepackageException: no such table: gps: , while compiling: select * FROM gps WHERE type="Agence"
09-11 13:57:33.312: W/System.err(6560): at android.database.sqlite.SQLiteCompiledSql.native_compile(Native Method)
09-11 13:57:33.328: W/System.err(6560): at android.database.sqlite.SQLiteCompiledSql.compile(SQLiteCompiledSql.java:92)
09-11 13:57:33.328: W/System.err(6560): at android.database.sqlite.SQLiteCompiledSql.<init>(SQLiteCompiledSql.java:65)
09-11 13:57:33.328: W/System.err(6560): at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:83)
09-11 13:57:33.343: W/System.err(6560): at android.database.sqlite.SQLiteQuery.<init>(SQLiteQuery.java:49)
09-11 13:57:33.343: W/System.err(6560): at android.database.sqlite.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:42)
09-11 13:57:33.359: W/System.err(6560): at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1358)
09-11 13:57:33.359: W/System.err(6560): at android.database.sqlite.SQLiteDatabase.rawQuery(SQLiteDatabase.java:1326)
09-11 13:57:33.359: W/System.err(6560): at package.db.DBHelper.getArticlesList(DBHelper.java:234)
09-11 13:57:33.359: W/System.err(6560): at package.maps.Map$loadingTask.doInBackground(Map.java:656)
09-11 13:57:33.375: W/System.err(6560): android.database.sqlite.SQLiteException: no such table: gps: , while compiling: select * FROM gps WHERE type="Agence"
09-11 13:57:33.375: W/System.err(6560): at android.database.sqlite.SQLiteCompiledSql.native_compile(Native Method)
09-11 13:57:33.382: W/System.err(6560): at android.database.sqlite.SQLiteCompiledSql.compile(SQLiteCompiledSql.java:92)
09-11 13:57:33.382: W/System.err(6560): at android.database.sqlite.SQLiteCompiledSql.<init>(SQLiteCompiledSql.java:65)
09-11 13:57:33.382: W/System.err(6560): at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:83)
09-11 13:57:33.382: W/System.err(6560): at android.database.sqlite.SQLiteQuery.<init>(SQLiteQuery.java:49)
09-11 13:57:33.382: W/System.err(6560): at android.database.sqlite.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:42)
09-11 13:57:33.382: W/System.err(6560): at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1358)
09-11 13:57:33.382: W/System.err(6560): at android.database.sqlite.SQLiteDatabase.rawQuery(SQLiteDatabase.java:1326)
09-11 13:57:33.382: W/System.err(6560): at package.db.DBHelper.getArticlesList(DBHelper.java:234)
09-11 13:57:33.382: W/System.err(6560): at package.maps.Map$loadingTask.doInBackground(Map.java:656)
09-11 13:57:33.382: W/System.err(6560): at package.maps.Map$loadingTask.doInBackground(Map.java:1)
09-11 13:57:33.382: W/System.err(6560): at android.os.AsyncTask$2.call(AsyncTask.java:185)
09-11 13:57:33.382: W/System.err(6560): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:306)
09-11 13:57:33.382: W/System.err(6560): at java.util.concurrent.FutureTask.run(FutureTask.java:138)
09-11 13:57:33.382: W/System.err(6560): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1088)
09-11 13:57:33.382: W/System.err(6560): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:581)
09-11 13:57:33.382: W/System.err(6560): at java.lang.Thread.run(Thread.java:1019)
09-11 13:57:33.382: W/System.err(6560): at android.database.sqlite.SQLiteCompiledSql.native_compile(Native Method)
09-11 13:57:33.382: W/System.err(6560): at android.database.sqlite.SQLiteCompiledSql.compile(SQLiteCompiledSql.java:92)
09-11 13:57:33.382: W/System.err(6560): at android.database.sqlite.SQLiteCompiledSql.<init>(SQLiteCompiledSql.java:65)
09-11 13:57:33.382: W/System.err(6560): at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:83)
09-11 13:57:33.382: W/System.err(6560): at android.database.sqlite.SQLiteQuery.<init>(SQLiteQuery.java:49)
09-11 13:57:33.382: W/System.err(6560): at android.database.sqlite.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:42)
09-11 13:57:33.382: W/System.err(6560): at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1358)
09-11 13:57:33.382: W/System.err(6560): at android.database.sqlite.SQLiteDatabase.rawQuery(SQLiteDatabase.java:1326)
09-11 13:57:33.382: W/System.err(6560): at package.db.DBHelper.getArticlesList(DBHelper.java:234)
09-11 13:57:33.382: W/System.err(6560): at package.maps.Map$loadingTask.doInBackground(Map.java:656)
09-11 13:57:33.382: W/System.err(6560): at package.maps.Map$loadingTask.doInBackground(Map.java:1)
09-11 13:57:33.382: W/System.err(6560): at android.os.AsyncTask$2.call(AsyncTask.java:185)
09-11 13:57:33.382: W/System.err(6560): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:306)
09-11 13:57:33.382: W/System.err(6560): at java.util.concurrent.FutureTask.run(FutureTask.java:138)
09-11 13:57:33.382: W/System.err(6560): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1088)
09-11 13:57:33.382: W/System.err(6560): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:581)
09-11 13:57:33.382: W/System.err(6560): at java.lang.Thread.run(Thread.java:1019)
09-11 13:57:33.382: W/System.err(6560): android.database.sqlite.SQLiteException: no such table: gps: , while compiling: select * FROM gps WHERE type="Agence"
09-11 13:57:33.382: W/System.err(6560): at android.database.sqlite.SQLiteCompiledSql.native_compile(Native Method)
09-11 13:57:33.382: W/System.err(6560): at android.database.sqlite.SQLiteCompiledSql.compile(SQLiteCompiledSql.java:92)
09-11 13:57:33.382: W/System.err(6560): at android.database.sqlite.SQLiteCompiledSql.<init>(SQLiteCompiledSql.java:65)
09-11 13:57:33.382: W/System.err(6560): at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:83)
09-11 13:57:33.382: W/System.err(6560): at android.database.sqlite.SQLiteQuery.<init>(SQLiteQuery.java:49)
09-11 13:57:33.382: W/System.err(6560): at android.database.sqlite.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:42)
09-11 13:57:33.382: W/System.err(6560): at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1358)
09-11 13:57:33.382: W/System.err(6560): at android.database.sqlite.SQLiteDatabase.rawQuery(SQLiteDatabase.java:1326)
09-11 13:57:33.382: W/System.err(6560): at package.db.DBHelper.getArticlesList(DBHelper.java:234)
09-11 13:57:33.382: W/System.err(6560): at package.maps.Map$loadingTask.doInBackground(Map.java:656)
09-11 13:57:33.382: W/System.err(6560): at package.maps.Map$loadingTask.doInBackground(Map.java:1)
09-11 13:57:33.382: W/System.err(6560): at android.os.AsyncTask$2.call(AsyncTask.java:185)
09-11 13:57:33.382: W/System.err(6560): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:306)
09-11 13:57:33.382: W/System.err(6560): at java.util.concurrent.FutureTask.run(FutureTask.java:138)
09-11 13:57:33.382: W/System.err(6560): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1088)
09-11 13:57:33.382: W/System.err(6560): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:581)
09-11 13:57:33.390: W/System.err(6560): at package.maps.Map$loadingTask.doInBackground(Map.java:1)
09-11 13:57:33.390: W/System.err(6560): at android.os.AsyncTask$2.call(AsyncTask.java:185)
09-11 13:57:33.390: W/System.err(6560): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:306)
09-11 13:57:33.390: W/System.err(6560): at java.util.concurrent.FutureTask.run(FutureTask.java:138)
09-11 13:57:33.390: W/System.err(6560): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1088)
09-11 13:57:33.390: W/System.err(6560): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:581)
09-11 13:57:33.390: W/System.err(6560): at java.lang.Thread.run(Thread.java:1019)
09-11 13:57:33.414: W/System.err(6560): android.database.sqlite.SQLiteException: no such table: gps: , while compiling: select * FROM gps WHERE type="Agence"
09-11 13:57:33.414: W/System.err(6560): at android.database.sqlite.SQLiteCompiledSql.native_compile(Native Method)
09-11 13:57:33.414: W/System.err(6560): at android.database.sqlite.SQLiteCompiledSql.compile(SQLiteCompiledSql.java:92)
09-11 13:57:33.414: W/System.err(6560): at android.database.sqlite.SQLiteCompiledSql.<init>(SQLiteCompiledSql.java:65)
09-11 13:57:33.414: W/System.err(6560): at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:83)
09-11 13:57:33.414: W/System.err(6560): at android.database.sqlite.SQLiteQuery.<init>(SQLiteQuery.java:49)
09-11 13:57:33.414: W/System.err(6560): at android.database.sqlite.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:42)
09-11 13:57:33.414: W/System.err(6560): at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1358)
09-11 13:57:33.414: W/System.err(6560): at android.database.sqlite.SQLiteDatabase.rawQuery(SQLiteDatabase.java:1326)
09-11 13:57:33.414: W/System.err(6560): at package.db.DBHelper.getArticlesList(DBHelper.java:234)
09-11 13:57:33.414: W/System.err(6560): at package.maps.Map$loadingTask.doInBackground(Map.java:656)
09-11 13:57:33.414: W/System.err(6560): at package.maps.Map$loadingTask.doInBackground(Map.java:1)
09-11 13:57:33.414: W/System.err(6560): at android.os.AsyncTask$2.call(AsyncTask.java:185)
09-11 13:57:33.414: W/System.err(6560): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:306)
09-11 13:57:33.414: W/System.err(6560): at java.util.concurrent.FutureTask.run(FutureTask.java:138)
09-11 13:57:33.414: W/System.err(6560): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1088)
09-11 13:57:33.414: W/System.err(6560): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:581)
09-11 13:57:33.414: W/System.err(6560): at java.lang.Thread.run(Thread.java:1019)
09-11 13:57:33.414: W/dalvikvm(6560): threadid=25: thread exiting with uncaught exception (group=0x40018578)
09-11 13:57:33.421: W/System.err(6560): android.database.sqlite.SQLiteException: no such table: gps: , while compiling: select * FROM gps WHERE type="Agence"
09-11 13:57:33.421: W/System.err(6560): at android.database.sqlite.SQLiteCompiledSql.native_compile(Native Method)
09-11 13:57:33.421: W/System.err(6560): at android.database.sqlite.SQLiteCompiledSql.compile(SQLiteCompiledSql.java:92)
09-11 13:57:33.421: W/System.err(6560): at android.database.sqlite.SQLiteCompiledSql.<init>(SQLiteCompiledSql.java:65)
09-11 13:57:33.421: W/System.err(6560): at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:83)
09-11 13:57:33.421: W/System.err(6560): at android.database.sqlite.SQLiteQuery.<init>(SQLiteQuery.java:49)
09-11 13:57:33.421: W/System.err(6560): at android.database.sqlite.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:42)
09-11 13:57:33.445: W/dalvikvm(6560): threadid=26: thread exiting with uncaught exception (group=0x40018578)
*
在我的数据库中,表格gps存在,但在上面的日志中(没有这样的表:gps :,编译时:select * FROM gps WHERE type =“Agence”)它没有找到表格gps。起初我认为光标没有关闭。这怎么可能。我正在使用android 2.3来测试我的应用程序。
这是我的代码:
public class DBHelper {
private final String DATABASE_PATH = "/data/data/s../databases/";
private final String DATABASE_NAME = "bfcoi.sqlite";
private final static int DATABASE_VERSION = 1;
public static String mtype="Agence";
public static String db_help="ON";
private Context context;
private SQLiteDatabase database = null;
OpenHelper openHelper=null;
StringBuilder query =null;
Cursor cursor=null;
ArticlesTable articlesTable=new ArticlesTable();
DestinateurTable destinataireTable = new DestinateurTable();
MailSentTable mailsentTable= new MailSentTable();
public static DBHelper dbHelper = null;
private DBHelper(Context context) {
this.context = context;
openHelper = new OpenHelper(this.context);
this.database = openHelper.getWritableDatabase();
try {
createDataBase();
openDataBase();
} catch (IOException e) {
e.printStackTrace();
}
}
public static DBHelper getInstance(Context context)
{
if(dbHelper == null)
dbHelper = new DBHelper(context);
return dbHelper;
}
public void openDataBase() throws SQLException{
//Open the database
String myPath = DATABASE_PATH + DATABASE_NAME;
database = SQLiteDatabase.openDatabase(myPath, null,SQLiteDatabase.OPEN_READWRITE) ;
//SQLiteDatabase.NO_LOCALIZED_COLLATORS|SQLiteDatabase.SQLiteDatabase.OPEN_READWRITE);////
}
/**
* Creates a empty database on the system and rewrites it with your own database.
* */
public void createDataBase() throws IOException
{
openHelper.getReadableDatabase();
if(getDBAlreadyCopiedToDeviceOnceFlag(context) == false){
try {
copyDataBase();
setDBAlreadyCopiedToDeviceOnceFlag(context);
} catch (IOException e) {
e.printStackTrace();
throw new Error("Error copying database");
}
}
}
/**
* Check if the database already exist to avoid re-copying the file each time you open the application.
* @return true if it exists, false if it doesn't
*/
private boolean checkDataBase(){
SQLiteDatabase checkDB = null;
try{
String myPath = DATABASE_PATH + DATABASE_NAME;
checkDB = SQLiteDatabase.openDatabase(myPath, null,SQLiteDatabase.OPEN_READWRITE);
}catch(SQLiteException e){
//database does't exist yet.
}
if(checkDB != null){
checkDB.close();
}
return checkDB != null ? true : false;
}
/**
* Copies your database from your local assets-folder to the just created empty database in the
* system folder, from where it can be accessed and handled.
* This is done by transfering bytestream.
* */
private void copyDataBase() throws IOException{
//Open your local db as the input stream
InputStream myInput = context.getAssets().open(DATABASE_NAME);
// Path to the just created empty db
String outFileName = DATABASE_PATH + DATABASE_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))>0){
myOutput.write(buffer, 0, length);
}
//Close the streams
myOutput.flush();
myOutput.close();
myInput.close();
}
private class OpenHelper extends SQLiteOpenHelper
{
@SuppressWarnings("unused")
SQLiteStatement insertStmt;
public OpenHelper(Context context)
{
super(context, DATABASE_NAME, null, DATABASE_VERSION);
}
@Override
public void onCreate(SQLiteDatabase db)
{
// TODO Auto-generated method stub
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion)
{
// TODO Auto-generated method stub
}
}
public void setDBAlreadyCopiedToDeviceOnceFlag(Context ctx)
{
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(ctx);
SharedPreferences.Editor editor = prefs.edit();
editor.putBoolean("isDBAlreadyCopiedToDeviceOnce", true);
editor.commit();
}
public boolean getDBAlreadyCopiedToDeviceOnceFlag(Context ctx){
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(ctx);
boolean isDBAlreadyCopiedToDeviceOnce = prefs.getBoolean("isDBAlreadyCopiedToDeviceOnce", false);
return isDBAlreadyCopiedToDeviceOnce;
}
////////////////////////////
//// Write your methods here
////////////////////////////
public ArrayList<Article> getArticlesList() {
ArrayList<Article> items=new ArrayList<Article>();
try {
query = new StringBuilder();
/*
* SEARCH BY TYPE i.e. Distributeur/Agence
*/
if (db_help.equals("ON"))
query.append("select * FROM "+articlesTable.TABLE_NAME+" WHERE type=\""+mtype+"\"");
/*
* SEARCH / DISPLAY IN LISTVIEW
*/
else if (db_help.equals("EXEPTION")){
query.append("SELECT * FROM gps WHERE adresse6 LIKE '%"+MapsSearch.search_text_value+"%' OR adressE1 LIKE '%"+MapsSearch.search_text_value+"%' OR adresse2 LIKE '%"+MapsSearch.search_text_value+"%' OR adresse3 LIKE '%"+MapsSearch.search_text_value+"%' OR adresse4 LIKE '%"+MapsSearch.search_text_value+"%' OR adresse5 LIKE '%"+MapsSearch.search_text_value+"%' ");
}
/*
* NORMAL SEARCH
*/
else
query.append("SELECT * FROM gps WHERE adresse6 LIKE '%"+Map.search_text_value+"%' OR adressE1 LIKE '%"+Map.search_text_value+"%' OR adresse2 LIKE '%"+Map.search_text_value+"%' OR adresse3 LIKE '%"+Map.search_text_value+"%' OR adresse4 LIKE '%"+Map.search_text_value+"%' OR adresse5 LIKE '%"+Map.search_text_value+"%' ");
//select * FROM "+articlesTable.TABLE_NAME+" WHERE addresse1 LIKE%"+Masp.search_text_value+"%\" OR addresse2 LIKE%"+Map.search_text_value+"% OR addresse1 LIKE%"+Map.search_text_value+"%\" OR addresse4 LIKE%"+Map.search_text_value+"%\" OR addresse5 LIKE%"+Map.search_text_value+"%\"
cursor=this.database.rawQuery(query.toString(),null);
System.out.println("cursor: "+query.toString());
if (cursor.moveToFirst())
{
do
{
Article a=new Article();
a.setEnseigne(cursor.getString(cursor.getColumnIndex(articlesTable.ENSEIGNE)));
a.setTel(cursor.getString(cursor.getColumnIndex(articlesTable.TEL)));
a.setType(cursor.getString(cursor.getColumnIndex(articlesTable.TYPE)));
a.setFax(cursor.getString(cursor.getColumnIndex(articlesTable.FAX)));
a.setLatitude(cursor.getString(cursor.getColumnIndex(articlesTable.LATITUDE)));
a.setLongitude(cursor.getString(cursor.getColumnIndex(articlesTable.LONGITUDE)));
a.setNom(cursor.getString(cursor.getColumnIndex(articlesTable.NOM)));
a.setAdresse1(cursor.getString(cursor.getColumnIndex(articlesTable.ADRESSE1)));
a.setAdresse2(cursor.getString(cursor.getColumnIndex(articlesTable.ADRESSE2)));
a.setAdresse3(cursor.getString(cursor.getColumnIndex(articlesTable.ADRESSE3)));
a.setAdresse4(cursor.getString(cursor.getColumnIndex(articlesTable.ADRESSE4)));
a.setAdresse5(cursor.getString(cursor.getColumnIndex(articlesTable.ADRESSE5)));
a.setAdresse6(cursor.getString(cursor.getColumnIndex(articlesTable.ADRESSE6)));
a.setHoraires1(cursor.getString(cursor.getColumnIndex(articlesTable.HORAIRE1)));
a.setHoraires2(cursor.getString(cursor.getColumnIndex(articlesTable.HORAIRE2)));
a.setHoraires3(cursor.getString(cursor.getColumnIndex(articlesTable.HORAIRE3)));
a.setHoraires4(cursor.getString(cursor.getColumnIndex(articlesTable.HORAIRE4)));
a.setHoraires5(cursor.getString(cursor.getColumnIndex(articlesTable.HORAIRE5)));
a.setHoraires6(cursor.getString(cursor.getColumnIndex(articlesTable.HORAIRE6)));
a.setHoraires7(cursor.getString(cursor.getColumnIndex(articlesTable.HORAIRE7)));
items.add(a);
}
while (cursor.moveToNext());
}
if (cursor != null && !cursor.isClosed()){
cursor.close();
}
}
catch(SQLiteException e){
e.printStackTrace();
return null;
}
return items;
}
//--here
public boolean addArticle(Article a){
this.database.beginTransaction();
try{
ContentValues contentValues=new ContentValues();
contentValues.put(articlesTable.ENSEIGNE, a.enseigne);
contentValues.put(articlesTable.TEL, a.tel);
contentValues.put(articlesTable.FAX, a.fax);
contentValues.put(articlesTable.TYPE, a.type);
contentValues.put(articlesTable.LATITUDE, a.latitude);
contentValues.put(articlesTable.LONGITUDE, a.longitude);
contentValues.put(articlesTable.ADRESSE1, a.adresse1);
contentValues.put(articlesTable.ADRESSE2, a.adresse2);
contentValues.put(articlesTable.ADRESSE3, a.adresse3);
contentValues.put(articlesTable.ADRESSE4, a.adresse4);
contentValues.put(articlesTable.ADRESSE5, a.adresse5);
contentValues.put(articlesTable.ADRESSE6, a.adresse6);
contentValues.put(articlesTable.HORAIRE1, a.horaires1);
contentValues.put(articlesTable.HORAIRE2, a.horaires2);
contentValues.put(articlesTable.HORAIRE3, a.horaires3);
contentValues.put(articlesTable.HORAIRE4, a.horaires4);
contentValues.put(articlesTable.HORAIRE5, a.horaires5);
contentValues.put(articlesTable.HORAIRE6, a.horaires6);
contentValues.put(articlesTable.HORAIRE7, a.horaires7);
this.database.insert(articlesTable.TABLE_NAME,null,contentValues);
this.database.setTransactionSuccessful();
}catch(Exception e){
e.printStackTrace();
return false;
}finally{
this.database.endTransaction();
}
return true;
}
public boolean deleteArticle(String id){
try
{
String query="delete from " + articlesTable.TABLE_NAME+" where "+articlesTable.NOM+"='"+id+"'";
this.database.execSQL(query);
}
catch(SQLiteException e){
e.printStackTrace();
return false;
}
return true;
}
更新:表格gps仅在Android 2.3及更低版本中缺失!我在设备4.1.2及更高版本上编译源代码,它可以工作。我的问题是在Android 2.3及以下版本。
答案 0 :(得分:0)
从您的日志中
no such table: gps: , while compiling: select * FROM gps WHERE type="Agence".
确保你拥有它并在之前构建。
在OpenHelper
课程中,您有方法onCreate
,实际上您生成了表格。
@Override
public void onCreate(SQLiteDatabase db)
{
db.execSQL("CREATE TABLE gps .......
}
从您的代码中我们看不出您是如何构建它的。
顺便说一下,创建表格不是一个大问题,如果你没有,不用担心,但通过这种方式你可以防止上述错误。