hi, i have a problem while follow the link as:
http://sqlcipher.net/sqlcipher-api/#key
and
http://sqlcipher.net/sqlcipher-for-android/
while executing
database.execSQL("ATTACH DATABASE '/data/data/com.SqlcipherSample/
databases/plaintext.db' AS plaintext KEY '';");
it keeping telling me that
05-04 19:00:02.312: ERROR/AndroidRuntime(16691): Caused by:
info.guardianproject.database.sqlcipher.SQLiteException: unable to
open database: plaintext.db: ATTACH DATABASE 'plaintext.db' AS
plaintext KEY '';
below is my complete file, is there any way to fix it?
Thanks very much.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
package com.SqlcipherSample;
import java.io.File;
import java.io.IOException;
import android.app.Activity;
import info.guardianproject.database.sqlcipher.SQLiteDatabase;
import android.os.Bundle;
public class main extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
InitializeSQLCipher();
}
private void InitializeSQLCipher() {
SQLiteDatabase.loadLibs(this);
File databaseFile = getDatabasePath("demo.db");
databaseFile.mkdirs();
databaseFile.delete();
SQLiteDatabase database =
SQLiteDatabase.openOrCreateDatabase(databaseFile, "test123", null);
database.execSQL("create table t1(a, b)");
database.execSQL("insert into t1(a, b) values(?, ?)", new
Object[]{"one for the money",
"two for the show"});
File plaintextFile = getDatabasePath("plaintext.db");
try {
plaintextFile.createNewFile();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
database.execSQL("PRAGMA key = 'test123'");
database.execSQL("ATTACH DATABASE '/data/data/
com.SqlcipherSample/databases/plaintext.db' AS plaintext KEY '';");
database.execSQL("SELECT sqlcipher_export('plaintext'); ");
database.execSQL("DETACH DATABASE plaintext;");
}
}