android - SQLite exception in Jelly bean but not in marshmallow -
i upgraded app marshmallow , getting sqlite database full exception. db code is,
package com.app; import java.io.file; import android.content.contentvalues; import android.content.context; import android.database.cursor; import android.database.sqlite.sqlitedatabase; import android.database.sqlite.sqliteopenhelper; import android.os.environment; import android.util.log; public class sqlitedb extends sqliteopenhelper{ private static final string database="appname"; private static final int version=8; private static final string create_table_todo = "create table user (" + "id" + " integer," + "value" + " integer" + ")"; private static final string create_table_todo1 = "create table trend (id integer,url text,image text,title text,count integer,height text,width text,points integer,sourceavail text)"; private static final string create_table_todo2 = "create table random (id integer,url text,image text,title text,count integer,height text,width text,points integer,sourceavail text)"; public sqlitedb(final context context) { super(context, environment.getexternalstoragedirectory() + file.separator + "appname" + file.separator + database , null, version); } public static sqlitedatabase openorcreatedatabase (string dbfile,sqlitedatabase.cursorfactory factory) { return null; } @override public void oncreate(sqlitedatabase db) { db.execsql(create_table_todo1); db.execsql(create_table_todo2); } @override public void onupgrade(sqlitedatabase db, int oldversion, int newversion) { if(oldversion < 7) { db.execsql("drop table if exists user"); oncreate(db); } if(newversion == 8){ db.execsql(create_table_todo1); db.execsql(create_table_todo2); } } public cursor getdetails(string table) { // todo auto-generated method stub string selectquery = "select * "+table+" order id desc"; sqlitedatabase db = this.getreadabledatabase(); cursor c = db.rawquery(selectquery, null); return c; } public cursor getdetails(string table,integer integer) { // todo auto-generated method stub string selectquery = "select * "+table+" id='"+integer+"'"; sqlitedatabase db = this.getreadabledatabase(); cursor c = db.rawquery(selectquery, null); return c; } public void deletedata(string table) { // todo auto-generated method stub sqlitedatabase db=this.getwritabledatabase(); db.delete(table, null, null); }
}
from mainpage,
sqlitedb db = new sqlitedb(getactivity()); cursor c = db.getdetails("trend");
the tables created in marshmallow not in jelly bean. database created can access sqlite_master , android_metadata tables. tried adding getwritabledatabase(); constructor of sqlitedb. looks oncreate not executed.
strack trace:
09-14 08:44:53.890: e/androidruntime(25054): fatal exception: main 09-14 08:44:53.890: e/androidruntime(25054): android.database.sqlite.sqlitefullexception: database or disk full (code 13) 09-14 08:44:53.890: e/androidruntime(25054): @ android.database.sqlite.sqliteconnection.nativeexecute(native method) 09-14 08:44:53.890: e/androidruntime(25054): @ android.database.sqlite.sqliteconnection.execute(sqliteconnection.java:552) 09-14 08:44:53.890: e/androidruntime(25054): @ android.database.sqlite.sqlitesession.endtransactionunchecked(sqlitesession.java:437) 09-14 08:44:53.890: e/androidruntime(25054): @ android.database.sqlite.sqlitesession.endtransaction(sqlitesession.java:401) 09-14 08:44:53.890: e/androidruntime(25054): @ android.database.sqlite.sqlitedatabase.endtransaction(sqlitedatabase.java:522) 09-14 08:44:53.890: e/androidruntime(25054): @ android.database.sqlite.sqliteopenhelper.getdatabaselocked(sqliteopenhelper.java:263) 09-14 08:44:53.890: e/androidruntime(25054): @ android.database.sqlite.sqliteopenhelper.getreadabledatabase(sqliteopenhelper.java:188) 09-14 08:44:53.890: e/androidruntime(25054): @ com.app.db.sqlitedb.getdetails(sqlitedb.java:188) 09-14 08:44:53.890: e/androidruntime(25054): @ com.app.trendactivity.oncreateview(trendactivity.java:119) 09-14 08:44:53.890: e/androidruntime(25054): @ android.support.v4.app.fragment.performcreateview(fragment.java:1962) 09-14 08:44:53.890: e/androidruntime(25054): @ android.support.v4.app.fragmentmanagerimpl.movetostate(fragmentmanager.java:1016) 09-14 08:44:53.890: e/androidruntime(25054): @ android.support.v4.app.fragmentmanagerimpl.movetostate(fragmentmanager.java:1197) 09-14 08:44:53.890: e/androidruntime(25054): @ android.support.v4.app.backstackrecord.run(backstackrecord.java:738) 09-14 08:44:53.890: e/androidruntime(25054): @ android.support.v4.app.fragmentmanagerimpl.execpendingactions(fragmentmanager.java:1562) 09-14 08:44:53.890: e/androidruntime(25054): @ android.support.v4.app.fragmentmanagerimpl.executependingtransactions(fragmentmanager.java:535) 09-14 08:44:53.890: e/androidruntime(25054): @ android.support.v4.app.fragmentstatepageradapter.finishupdate(fragmentstatepageradapter.java:163) 09-14 08:44:53.890: e/androidruntime(25054): @ android.support.v4.view.viewpager.populate(viewpager.java:1106) 09-14 08:44:53.890: e/androidruntime(25054): @ android.support.v4.view.viewpager.populate(viewpager.java:952) 09-14 08:44:53.890: e/androidruntime(25054): @ android.support.v4.view.viewpager.onmeasure(viewpager.java:1474) 09-14 08:44:53.890: e/androidruntime(25054): @ android.view.view.measure(view.java:15635) 09-14 08:44:53.890: e/androidruntime(25054): @ android.view.viewgroup.measurechildwithmargins(viewgroup.java:4919)
it working fine in marshmallow added realtime permission request. please help.
from sqlite documentation
(13) sqlite_full
the sqlite_full result code indicates write not complete because disk full. note error can occur when trying write information main database file, or can occur when writing temporary disk files. applications encounter error though there abundance of primary disk space because error occurs when writing temporary disk files on system temporary files stored on separate partition less space primary disk. https://www.sqlite.org/rescode.html#full
i guess application installed on sdcard or someth
if disk full. ran out of disk space
Comments
Post a Comment