Android - SQLite database on SD card

前端 未结 2 1831
再見小時候
再見小時候 2020-12-18 06:59

is there any way, how to create and use database from SD card in my app instead of /data/data/com.myapp/databases directory? I know is it unsecure, but are there any special

2条回答
  •  感动是毒
    2020-12-18 07:59

    he is a proposed solution which i found in stackoverflow

    File dbfile = new File("/sdcard/android/com.myapp/databases/mydatabase.db" ); 
    SQLiteDatabase db = SQLiteDatabase.openOrCreateDatabase(dbfile, null);
    System.out.println("Its open? "  + db.isOpen());
    

    here is the link.

    UPDATE

    i am not sure you can use this along with SQLiteOpenHelper, but you sure can query the database object.

    db.getVersion();
    db.execSQL(sql);
    db.beginTransaction();
    db.endTransaction();
    db.setTransactionSuccessful();
    db.query(table, columns, selection, selectionArgs, groupBy, having, orderBy);
    

    you can do all the things which you expect with a database. SQLiteOpenHelper in only a wrapper class which helps you the extra which we always can do on our own.

    EDIT as for your file size limit i found this link. Is there a file size limit on Android Honeycomb?

提交回复
热议问题