0

我想使用 SQLiteCipher 从 sdcard 创建一个数据库,但在设备文件资源管理器中给我未从 ExternalStorage/RemovableSDCard 更新的日期和时间。

DBHelpers.Java

public class DBHelpers extends SQLiteOpenHelper {

    private static DBHelpers instance;


    public static final int DATABASE_VERSION = 1;
    public static final String DATABASE_NAME = "Data.db";

    private static final String TEXT_TYPE = " TEXT";
    private static final String SQL_CREATE_ENTRIES = ...;

    private static final String SQL_DELETE_ENTRIES =
            "DROP TABLE IF EXISTS " + ...;

    public DBHelpers(Context context) {
        super(context, DATABASE_NAME, null, DATABASE_VERSION);
    }

    static public synchronized DBHelpers getInstance(Context context) {
        if (instance == null) {
            instance = new DBHelpers(context);
        }
        return instance;
    }

    public void onCreate(SQLiteDatabase db) {
        db.execSQL(SQL_CREATE_ENTRIES);
    }
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        db.execSQL(SQL_DELETE_ENTRIES);
        onCreate(db);
    }

MainActivity.java

SQliteDatabase database;
SQLiteDatabase.loadLibs(getContext());
String password = "password";
String path = "/storage/sdcard1/";
database = SQLiteDatabase.openOrCreateDatabase(path+"Data.db",password,null);

AndroidManifest.xml

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
4

0 回答 0