这是我的数据库设计。我有2个表“ Donation_Details ”和“ 信息”。让我澄清一下,现在我不能把这两个表叫出来了,这是什么问题?我被困在这里将近1天...我试图自己找到答案,但根本没有答案...
这是我的DatabaseOpenHelper
public class DatabaseOpenHelper extends SQLiteAssetHelper {
private static final String DATABASE_NAME = "eBossCharity.db";
private static final int DATABASE_VERSION = 1;
public DatabaseOpenHelper(Context context) {
super(context, DATABASE_NAME, null, DATABASE_VERSION);
}
这是我的数据库访问权限
public class DatabaseAccess {
private SQLiteOpenHelper openHelper;
private SQLiteDatabase db;
private static DatabaseAccess instance;
Cursor c = null;
private DatabaseAccess(Context context) {
this.openHelper = new DatabaseOpenHelper(context);
}
public static DatabaseAccess getInstance(Context context) {
if (instance == null) {
instance = new DatabaseAccess(context);
}
return instance;
}
public void open() {
this.db = openHelper.getWritableDatabase();
}
public void close() {
if (db != null) {
this.db.close();
}
}
public String getAddress(String name){
c=db.rawQuery("Select * from Information ",new String[]{});
StringBuffer buffer =new StringBuffer();
while (c.moveToNext()){
String address = c.getString(0);
String address1 = c.getString(1);
buffer.append(" "+ address +" "+ address1);
}
return buffer.toString();
}
}
这是我的Java页面
public void onClick(View v) {
DatabaseAccess databaseAccess = DatabaseAccess.getInstance(getApplicationContext());
databaseAccess.open();
try {
String n = summary_showAll.getText().toString();
String address = databaseAccess.getAddress(n);
summary_showAll.setText(address);
databaseAccess.close();
} catch (Exception e) {
e.printStackTrace();
}
}
我是否键入错误导致此错误?
答案 0 :(得分:0)
我也有同样的情况。您所需要做的就是卸载和重新安装您的应用。它为我工作。
希望有帮助。