Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android - SQLite database on SD card

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 restriction like "database on SD card cannot be bigger then 2GB"?

Thanks

Hmyzak

like image 290
Waypoint Avatar asked Aug 29 '11 08:08

Waypoint


People also ask

Where is the SQLite database stored in Android?

The Android SDK provides dedicated APIs that allow developers to use SQLite databases in their applications. The SQLite files are generally stored on the internal storage under /data/data/<packageName>/databases.

Does SQLite load database into memory?

An SQLite database is normally stored in a single ordinary disk file. However, in certain circumstances, the database might be stored in memory. The most common way to force an SQLite database to exist purely in memory is to open the database using the special filename ":memory:".

What is SQLite Sdcard storage DB?

SQLite is an open-source relational database i.e. used to perform database operations on android devices such as storing, manipulating or retrieving persistent data from the database. It is embedded in android bydefault. So, there is no need to perform any database setup or administration task.

Can I store SQLite database on Google Drive?

Uploading-SQLite-Database-to-Google-Drive-in-AndroidCreate a new app in android studio. Register and "enable" "Google Drive Api" and Google Drive SDK. Create Java files- MainActivity. java and CloudBackup.


1 Answers

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?

like image 155
Samuel Avatar answered Sep 18 '22 12:09

Samuel