在我搜索之后,我发现最好将sqlite数据库的所有数据存储在XML文件中,然后从中提取数据。我试过但每次都有一些我无法理解的错误。
有没有更好的方法来实现我的目标?
这是创建数据库的代码:
public class DatabaseHelper extends SQLiteOpenHelper {
public static final String dataBase_Name="dbProject";
private static final String table_name="dbImages";
private static final int database_version=1;
private static final String UID="id";
private static final String NAME="name";
private static final String IMAGE="images";
private static final String Create_Images_Table= "CREATE TABLE "+table_name
+" (" +UID+ " INTEGER PRIMARY KEY AUTOINCREAMENT , "+NAME
+" VARCHAR(255) , " +IMAGE +" Blob );";
public DatabaseHelper(Context context) {
super(context, dataBase_Name, null,database_version);
}
public DatabaseHelper(Context context, String name, SQLiteDatabase.CursorFactory factory, int version, DatabaseErrorHandler errorHandler) {
super(context, name, factory, version, errorHandler);
}
@Override
public void onCreate(SQLiteDatabase db) {
db.execSQL(Create_Images_Table);
Log.v("DbAdapter", "Image Table Created.");
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
}
}
这是xml文件的代码
<p>
<content>
<name> black board </name>
<images> blackboard.bmp</images>
</content>
<content>
<name> chair </name>
<images>chair.bmp</images>
</content>
<content>
<name>desk</name>
<images>desk.bmp</images>
</content>
<content>
<name> door </name>
<images>door.bmp</images>
</content>
<content>
<name>glass window</name>
<images>glassWindow.bmp</images>
</content>
<content>
<name> wall </name>
<images> wall.bmp </images>
</content>
<content>
<name>window</name>
<images>window.bmp</images>
</content>
<content>
<name>wooden chair</name>
<images>woodenChair.bmp</images>
</content>
</p>
这是我收到的错误:
错误:错误:不支持的类型&#39; p&#39;