tags:

views:

10311

answers:

5

is there a way to store android application data on the SDCard instead of the internal memory? I know how to transfer the application sqlite database from the internal memory to the SDCard, but what if the internal memory gets full in the first place? how does everyone handle this?

+1  A: 

Adding /sdcard/ to the root your path should direct your Android application to use the SD card (at least it works that way with the G1). Android's file system objects give you the ability to check file sizes...so it should be possible (if tricky) to write some fail-over code. This code would adjust your root path if the internal memory filled up.

haseman
how do you adjust the root path?
Adjust the root path that you're using. (That was a bit confusing...you can't alter Android's root path)
haseman
I'm using SQLiteDatabase to create the database, however the name argument of it's constructor can't contain a path, how is it possible that I create the database on the sdcard?
http://developer.android.com/reference/android/database/sqlite/SQLiteDatabase.html#openDatabase%28java.lang.String,%20android.database.sqlite.SQLiteDatabase.CursorFactory,%20int%29Use the openDatabase call. It takes a path as the first parameter
haseman
what is I'm using a SQLiteOpenHelper, it doesn't take any path.
+1  A: 

The problem with using the SDCard is that you cannot reliably assume that it will be present always when your application needs it. This is not the case with internal memory. As long as your application does not rely on this data to run it should be fine.

Prashast
+17  A: 

It's better practice to use Environment.getExternalStorageDirectory() than to hard code "/sdcard" It's not always certain that the folder name will be called that. Also, the Environment class offers a getExternalStorageState() method to check on if the external storage is even available.

yincrash
A: 

user121196, sorry to ask a question within your question, but i see you said "I know how to transfer the application sqlite database from the internal memory to the SDCard". I been trying to look for a example/tutorial/code snippet of how this can be done. Can you guide me, please?

Trebak
Use comments for a question like this, not "answer question".
I82Much
A: 

hi... am working on a video player project on android phone... but i dnt kno how to store videos in the application itself........ when the user installs this application he shud get the 3gp videos within the application ........user need nt can any one help me out pls..?and can anyone tel me the process of creating sdcard image for emulator

hema