作者:奥奥奥尼瀚 | 来源:互联网 | 2023-05-17 13:41
ImdevelopinganAndroidapplicationandimusingaSqlitedatabasetostoresomebitmaps.Iwant
I'm developing an Android application and i'm using a Sqlite database to store some bitmaps. I want some images to be automatically inserted when the user installs the application.
我正在开发一个Android应用程序,我正在使用Sqlite数据库来存储一些位图。我希望在用户安装应用程序时自动插入一些图像。
I'm using the SQLiteOpenHelper class like this:
我正在使用SQLiteOpenHelper类,如下所示:
public class DatabaseHelper extends SQLiteOpenHelper {
...
DatabaseHelper(Context context, String nameOfDB, int version, String[] scriptSQLCreate,
String scriptSQLDelete) {
super(context, nameOfDB, null, version);
this.scriptSQLCreate = scriptSQLCreate;
this.scriptSQLDelete = scriptSQLDelete;
}
@Override
public void onCreate(SQLiteDatabase db) {
int numScripts = scriptSQLCreate.length;
for(int i = 0; i
...
...
I want to pass a constant to the scriptSQLCreate parameter shown above that would be like so:
我想将一个常量传递给上面显示的scriptSQLCreate参数,如下所示:
private static final String[] SCRIPT_DATABASE_CREATE = {
"create table memes( id integer primary key autoincrement," +
+ " img blob not null," +
+ " name text not null unique)" ,
"insert into memes(img,name) values(BITMAP1,'1.jpg')",
"insert into memes(img,name) values(BITMAP2,'2.jpg')",
"insert into memes(img,name) values(BITMAP3,'3.jpg')"}
}
Any help will be much apreciated,
任何帮助都会被贬低,
Thx, Tulio Zahn
Thx,Tulio Zahn
2 个解决方案