我在Android上使用SQLite时遇到问题.我能够解析XML文件,然后创建一个数据库来存储内容.创作,插入工作正常.我可以在文件资源管理器中看到.db文件
我最后一次调用checkDataBase()会返回false?为什么?
我正在使用模拟器上的Android 2.3.
难道我做错了什么 ?
活动:
public class MTGDBActivity extends Activity{
String currentDBPath = "data/data/rudy.jaumain.mtgdb/databases/MTGCards";
MTGContainerData mtgcd;
MTGDatabase mtgdb;
Button buttonEditions, buttonCollection, buttonDecks;
View v;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
try {
this.mtgcd = new MTGContainerData(this);
if (!this.checkDataBase()) {
System.out.println("FILE DOESN'T EXIST");
this.mtgdb = new MTGDatabase(this);
this.mtgdb.open();
this.mtgcd.loadCards(this.mtgdb);
System.out.println("CARDS LOADED");
this.mtgdb.close();
}
else{
System.out.println("FILE DOES EXIST");
}
} catch (Exception e) {
System.out.println("FAIL");
}
System.out.println(this.checkDataBase());
this.setContentView(R.layout.main);
this.initialize();
} …Run Code Online (Sandbox Code Playgroud)