I am trying to do one thing in SQLCiper.
This thing succeeds in SQLite Database in SD-CARD
1- created one application firstApp . with database in SD-CARD
2- a second secondApp application has been secondApp .
I am trying to read data from an SD-CARD in my second application.
Edit: - My database is in sdcard.
public class SdcardCipherDataBase extends SQLiteOpenHelper { public static final String DATABASE_FILE_PATH = "/sdcard"; public static final String DATABASE_NAME = "sdCipherDatabase"; public final static String NAME ="name"; public final static String ADDRESS ="address"; public final static String CITY ="city"; public SdcardCipherDataBase(final Context context) { super(context,Environment.getExternalStorageDirectory()+File.separator+DATABASE_FILE_PATH + File.separator + DATABASE_NAME, null, 1); } @Override public void onCreate(SQLiteDatabase db) { try { db.execSQL( "CREATE TABLE information(_id INTEGER PRIMARY KEY AUTOINCREMENT,name TEXT, address TEXT,city TEXT);"); } catch (SQLiteException ex) { Log.e("Hello", "error -- " + ex.getMessage(), ex); } } @Override public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
I use this database in the same application: -
public void databasCollection() { SQLiteDatabase.loadLibs(this); File file = getDatabasePath("/mnt/sdcard/sdcard/sdCipherDatabase"); file.mkdir(); file.delete(); db = SQLiteDatabase.openOrCreateDatabase(file, "myapp", null); sdb = new SdcardCipherDataBase(this); sdb.getWritableDatabase("myapp"); ContentValues c = new ContentValues(); c.put(SdcardCipherDataBase.NAME,"monty"); c.put(SdcardCipherDataBase.ADDRESS,"BTM"); c.put(SdcardCipherDataBase.CITY,"Bangalore"); db.insert("information", SdcardCipherDataBase.NAME, c); db.close(); }
but I want to use the same database in another application.
I'm trying to do something like this
public void databaseFromOtherApp() { SQLiteDatabase.loadLibs(this); File file = getDatabasePath("/mnt/sdcard/sdcard/sdCipherDatabase"); db = SQLiteDatabase.openOrCreateDatabase(file, "myapp", null); dh = new DatabaseHelper(this); Cursor cursor = db.rawQuery("select * from information", null); cursor.moveToFirst(); String s = cursor.getString(cursor.getColumnIndex(NAME)); Toast.makeText(this,"Name is " +s, Toast.LENGTH_LONG).show(); cursor.close(); db.close(); }
but showing an error.
Caused by: net.sqlcipher.database.SQLiteException: no such table: information: , while compiling: select * from information