Kısa bir süre önce piyasaya bir uygulama yayınladım. Geliştiriciler konsolundan, kullanıcılarımızın yaklaşık% 1-2'sinin bu sorunu yaşıyor gibi görünüyor. % 1-2'si küçüktür, ancak kullanıcılar, bir şey çalışmadığında, indirme işlemlerini olumsuz yönde etkileyebileceklerinden daha fazla yorum yapma eğilimindedir. SQLiteException - sadece bazı cihazlarda gerçekleşiyor
Maalesef geliştiriciler konsol sadece 'öteki' olarak platformu listeler, ama benim app 1.6+ SDK olanlara mevcuttur. Ayrıca bu sorunu yeniden oluşturamıyorum ve hiçbir kullanıcı doğrudan benimle iletişim kurmadı. Bu nedenle, başarısız olduğu cihazlar hakkında daha fazla bilgi alamıyorum. Burada bilen varpublic List<Question> getQuestionSet(int difficulty, int numQ){
List<Question> questionSet = new ArrayList<Question>();
Cursor c = myDataBase.rawQuery("SELECT * FROM QUESTIONS WHERE DIFFICULTY=" + difficulty +
" ORDER BY RANDOM() LIMIT " + numQ, null);
while (c.moveToNext()){
//Log.d("QUESTION", "Question Found in DB: " + c.getString(1));
Question q = new Question();
q.setQuestion(c.getString(1));
q.setAnswer(c.getString(2));
q.setOption1(c.getString(3));
q.setOption2(c.getString(4));
q.setOption3(c.getString(5));
q.setRating(difficulty);
questionSet.add(q);
}
return questionSet;
}
}
belirtir
List<Question> questions = myDbHelper.getQuestionSet(diff, numQuestions);
için
android.database.sqlite.SQLiteException: no such table: QUESTIONS: , while compiling: SELECT * FROM QUESTIONS WHERE DIFFICULTY=2 ORDER BY RANDOM() LIMIT 20
at android.database.sqlite.SQLiteCompiledSql.native_compile(Native Method)
at android.database.sqlite.SQLiteCompiledSql.compile(SQLiteCompiledSql.java:91)
at android.database.sqlite.SQLiteCompiledSql.<init>(SQLiteCompiledSql.java:64)
at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:80)
at android.database.sqlite.SQLiteQuery.<init>(SQLiteQuery.java:46)
at android.database.sqlite.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:53)
at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1434)
at android.database.sqlite.SQLiteDatabase.rawQuery(SQLiteDatabase.java:1404)
at com.app.myapp.db.DBHelper.getQuestionSet(DBHelper.java:140)
at com.app.myapp.SplashActivity.getQuestionSetFromDb(SplashActivity.java:109)
at com.app.myapp.SplashActivity.onClick(SplashActivity.java:58)
at android.view.View.performClick(View.java:2421)
at android.view.View$PerformClick.run(View.java:8867)
at android.os.Handler.handleCallback(Handler.java:587)
at android.os.Handler.dispatchMessage(Handler.java:92)
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)
getQuestionSetFromDb (SplashActivity.java:109) anlamına gelir yığın arasında olası bir neden? Bunun sadece küçük bir miktar yükleme ile gerçekleşmesi ve kullandıkları SDK düzeyini/cihazını belirleyememesi daha zor hale gelmesi garip.
Herhangi bir yardım
EDIT takdir: nedeniyle db oluşturulur nasıl dahil ediyorum yanıtlara.
Birincisi benim etkinlik
private List<Question> getQuestionSetFromDb() throws Error {
int diff = getDifficultySettings();
int numQuestions = getNumQuestions();
DBHelper myDbHelper = new DBHelper(this);
try {
myDbHelper.createDataBase();
} catch (IOException ioe) {
throw new Error("Unable to create database");
}
try {
myDbHelper.openDataBase();
}catch(SQLException sqle){
throw sqle;
}
List<Question> questions = myDbHelper.getQuestionSet(diff, numQuestions);
myDbHelper.close();
return questions;
}
myDBhelper.createdatabase()
public void createDataBase() throws IOException{
boolean dbExist = checkDataBase();
if(!dbExist)
{
//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");
}
}
}
checkDatabase çağırır()
private boolean checkDataBase(){
SQLiteDatabase checkDB = null;
try{
String myPath = DB_PATH + DB_NAME;
checkDB = SQLiteDatabase.openDatabase(myPath, null, SQLiteDatabase.OPEN_READONLY);
}catch(SQLiteException e){
//database does't exist yet.
}
if(checkDB != null){
checkDB.close();
}
return checkDB != null ? true : false;
}
(bu çökertmesidir aynı yöntemdir) bu vardır
copyDatabase()
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))>0){
myOutput.write(buffer, 0, length);
}
//Close the streams
myOutput.flush();
myOutput.close();
myInput.close();
}
Değişkenler
private static String DB_PATH = "/data/data/com.app.myapp/databases/";
private static String DB_NAME = "questionsDb";
private SQLiteDatabase myDataBase;
private final Context myContext;
apoligies, gerçekten bir kayıp "SORULARI" veritabanında hakkında bu başlangıçta
DB şemasını yakın zamanda Sorular tablosunu içerecek şekilde yükseltdiniz mi? – hooked82
Hayır, veritabanı tabloları her zaman aynı olmuştur. Pazara yüklediğimden beri hiçbir veritabanı değişikliği olmadı. – PapaJon
Eh, hata açık görünüyor; masanız bulunamadı. Böylece, yaratılmaya çalışılan kısmına bakmaya başladım, her şeyin yaratıldığından emin olmak istiyorum. Ayrıca, bu belirli hatayı yakalamak ve gerçekleştiğinde tabloyu oluşturmak da bir fikir olabilir. –