Jin
Jin

Reputation: 6145

Android: SQLiteDatabase size

I am using the Android SQLiteDatabase in my application. Part of the application involves downloading a significant amount of data from a server and storing it on the phone's local db. Is there a way to find out how much space the database will actually take on the phone? I can't find any database-related files in the project folder.

Upvotes: 3

Views: 5614

Answers (2)

AutoM8R
AutoM8R

Reputation: 3080

If you're using Eclipse do this:

  1. Run or Debug your project.
  2. Open the File Explorer window.
  3. Scroll down the main /data directory until you find your package/databases/ (com.blabblah.appname/databases/) folder.

You will see your database in this directory. If you want to pull the DB from your phone, use the buttons at the top of the File Explorer window, the first button pulls a file from your device, the second button allows you to put a file on your device and the last button deletes the selected file.

I often grab my DB from my app in this regard and do some "offline" testing in SQLite clients, it's very handy.

Hope that helps.

Upvotes: 1

Vladimir
Vladimir

Reputation: 1532

The local SQLite database stores in Environment.getDataDirectory() + /data/<Package Name>/databases. Also you can call SQLiteDatabase$getPath() method.

SQLiteDatabase db;
// ...
long size = new File(db.getPath()).length();

Upvotes: 11

Related Questions