简体   繁体   中英

SQLite Database in Samsung Tab2 (External Micro sd card)

These are memory in my SAMSUNG TAB2.

1- Internal

2- Sdcard

3- **Extrenal_sdcard** (Removable memory) don't be confuse between sdcard and Extrenal_sdcard .

Extrenal_sdcard is micro sd card which we can remove from tab.

I was trying to create SQLite Database inside the Extrenal_sdcard (Removable).

But i didn't got success.

I was trying to do like what we do in Sdcard .

Environment.getExternalStorageState() +filename

but for Extrenal_sdcard (Removable) it was not working.

is it possible what i am trying to do or NOT.

please assist me.

Do not provide the link related How to create database in sdcard.

I haven't tried to do what you describe there, but presumably it could be done and might work -- with a few caveats. First, the external storage (SD card) is not secure, so any other application, or the user, could read/write to it. Second, as you noted, when it's unmounted the DB goes away.

Because of these disadvantages, you would probably be better off to try to use an internal storage database (the default), that is small and possibly includes pointers to external data (like images or files) -- that themselves can be on the external storage (and that have placeholders, or other handling, when the external storage is not available).

Still, if you want to try it, you might be better off override the getDatabasePath method of Context , such as with your own Application object, and then pass that into a regular SQLiteOpenHelper . Then you wouldn't have to worry about the cursor factory (which is optional, as the source confirms -- so just pass null if instead you want to go that route).

I got the answer.

WE need to provide this path for External Micro Sd card.

"/mnt/name_of_your_card/your_dbfile"

example:-

"/mnt/MyExternal_Card/My_database"

Thanks to this link.

How can I get external SD card path for Android 4.0+?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM