SQLite database location restriction

by Nathan » Fri, 13 Nov 2009 04:12:26 GMT

Sponsored Links
 I'm reading this restriction on where SQLite databases should reside
on Android.

All databases, SQLite and others, are stored on the device in /data/

While this may be appropriate for small databases that begin and end
within an application's space with a few contacts, this seems rather
restrictive for a large multimedia database that may be used on other
platforms, including Windows, and then transferred to a phone.

In particular, you apparently can't put a database file on a storage
card - which I know end users will want to do.

If this restriction is firm
1. How big can a file get in this location? I'll guess this is OEM
dependent, but, for example, the Verizon Droid is advertising 16GB
preinstalled memory. How much of this would be accessible to
databases? Anything that hasn't been used by the file system yet?
2. Is /data/data/<package_name>/databases a user accessible location
that end users will be able to browse to and place files in?



SQLite database location restriction

by Nathan » Fri, 13 Nov 2009 11:00:25 GMT

 It seems there is a hard restriction on where SQLite databases

All databases must be in /data/data/<package_name>/databases,
according to the spec. Specifically, they can't be on a storage card.

This seems ok if the database is a small one that begins and ends with
an adroid app. But for a 1 gig multimedia database that is transferred
from somewhere else, that is limiting.

If this restriction is firm:

1. Is this location user accessible? IE can an end user with an
unlocked phone copy files into there from their desktop computer or
storage card.
2. How much storage space is likely to be available in that location?.
On the 16G droid, for example, how. much of that 16G is accessible?



Sponsored Links

SQLite database location restriction

by westmeadboy » Fri, 13 Nov 2009 15:22:11 GMT

  http://developer.android.com/intl/en/reference/android/database/sqlite/SQLiteDatabase.html #openOrCreateDatabase(java.io.File,


SQLite database location restriction

by Nathan » Fri, 13 Nov 2009 15:44:17 GMT

 Yes, the method
public static SQLiteDatabase openOrCreateDatabase (File file,
SQLiteDatabase.CursorFactory factory)

makes it sound like you can open an arbitrary filename.

But the developer's guide

makes it sounds like you can't:

"All databases, SQLite and others, are stored on the device in /data/



SQLite database location restriction

by westmeadboy » Fri, 13 Nov 2009 15:50:27 GMT

 Yes, I can see that is misleading. I'm sure they just mean that for
when you don't specify a File.

Have you tried putting it on the sdcard? I have an app, used by
thousands of users, where a 20MB+ sqlite db file is located on the

Hope this helps!


SQLite database location restriction

by Nathan » Sat, 14 Nov 2009 01:23:04 GMT


Yes, it does. That's what I needed to know. I hadn't tried to code it
yet - I was reading the manual for once and found this tidbit that
could have big implications.

Given your experience, the chance that it will seem to work and then
blow up later sounds pretty small.



Other Threads

1. cropped picture with ImageView?

Dear developer,

I'd like to show a picture with the ImageView, but the picture should
be cropped.

Lets say the original picture is 250x250.

I'd like to show a 100x100 part of it.

To show the complete picture:

<ImageView android:id="@+id/bildchen"
android:layout_height="wrap_content" android:src="@drawable/bildchen" /

My first idea was to exchange wrap_content against 100px:

<ImageView android:id="@+id/bildchen" android:layout_width="100px"
android:layout_height="100px" android:src="@drawable/bildchen" />

But this didn't work at all. The picture just was stretched

So I played around with the attributes android:scaleType and
android:adjustViewBounds and android:cropToPadding - without any
results yet.

My last shot was to load the picture into the background instead of
the src.

Who helps me out on this?



Lieber Entwickler,

ich wrde gerne bei einem ImageView ein Bild in Originalauflsung
darstellen, allerdings abgeschnitten.

Sei die Grafik 250x250 Pixel gro.

Allerdings will ich nur 100x100 als Auschnitt darstellen.

Um das Bild vollstndig darzustellen:

<ImageView android:id="@+id/bildchen"
android:layout_height="wrap_content" android:src="@drawable/bildchen" /

Nun hatte ich gehofft, wenn ich statt wrap_content eine absolute Gre
eingebe, wurde die Grafik abgeschnitten werden:

<ImageView android:id="@+id/bildchen" android:layout_width="100px"
android:layout_height="100px" android:src="@drawable/bildchen" />

Leider wird das Bild proportional verkleinert. Ist ja schon mal nicht
schlecht, aber fhrt nicht zum gewnschten Ergebnis.

Ich hab dann mit den Attributen android:scaleType und
android:adjustViewBounds und android:cropToPadding rumgespielt aber
kein Ergebnis erzielen knnen.

Auch der Versuch die Grafik statt im src in den background zu laden
hat nicht den gewnschten Effekt erzielt.

Wer kann mir helfen?


PS: ich mchte spter mittels Tween Animation die Grafik in dem WIdget
scrollen; beispielsweise wie der On/Off Button beim iPhone...


2. Obtain unicode string for Roslien Language


I have an assignment to be completed.
The assignment needs sms texting service facility in Roslien Font (for
each  English alphabet we have a corresponding alphabet in Roslien,
something like  Wingdings) for Android platform.
On going through the posts available on different forums in internet,
I observed that in order to send a different language text, I need to
send the sms as a unicode string.
The problem is,  I have no  clue on how to obtain the unicode string
for a completely  new font , Roslien.
I have a " .ttf "  file for the font which as such which contains the
alphabets in the language.

Please help me , how do I obtain unicode string for the particular

Thanking You,

Srikant Aggarwal
Android Developer


3. Is it possible to always use a custom Instrumentation?

4. Database management

5. *Sharing SOFTWARE-SOFTWARE yang Keren-keren dong. Kira-kira APA?

6. *Sharing SOFTWARE-SOFTWARE yang Keren-keren dong. Kira-kira APA?

7. Bottom second Nexus