Questions tagged [android-sqlite]

Android uses SQLite to store and retrieve data persistently. Use this tag for questions regarding the Android implementation of SQLite, how to use it in your application, or for help when your implementation of SQLite doesn't work.

uses a SQLite database to store and retrieve data persistantly.

Every Android App gets a private SQLite database to persistantly store data.

See also

8244 questions
1000
votes
15 answers

Ship an application with a database

If your application requires a database and it comes with built in data, what is the best way to ship that application? Should I: Precreate the SQLite database and include it in the .apk? Include the SQL commands with the application and have it…
Heikki Toivonen
  • 30,964
  • 11
  • 42
  • 44
393
votes
18 answers

How to access data/data folder in Android device?

I am developing an app and I know my database *.db will appear in data/data/com.****.*** I can access this file from AVD in Eclipse with help of sqlite manager But I can't access this file in my Android phone. I googled it and it says I need to root…
Naveen Prince P
  • 4,521
  • 3
  • 16
  • 17
319
votes
15 answers

When does SQLiteOpenHelper onCreate() / onUpgrade() run?

I have created my tables in my SQLiteOpenHelper onCreate() but receive SQLiteException: no such table or SQLiteException: no such column errors. Why? NOTE: (This is the amalgamated summary of tens of similar questions every week. Attempting to…
laalto
  • 150,114
  • 66
  • 286
  • 303
297
votes
31 answers

View contents of database file in Android Studio

I have been using Android Studio to develop my app since it's was released. Everything works nice until recently, I have to debug together with checking the database file. Since I don't know how to see the database directly, When I debugged to…
Scott Zhu
  • 8,341
  • 6
  • 31
  • 38
122
votes
12 answers

Retrieve database or any other file from the Internal Storage using run-as

On a non-rooted android device, I can navigate to the data folder containing the database using the run-as command with my package name. Most files types I am content with just viewing, but with the database I would like to pull if from the android…
CQM
  • 42,592
  • 75
  • 224
  • 366
93
votes
2 answers

Where does Android store SQLite's database version?

I am unable to find where Android stores the database version within the SQLite database file. Where exactly is the database version stored?
bhups
  • 14,345
  • 8
  • 49
  • 57
79
votes
10 answers

SQLite Order By Date1530019888000

Every record in my SQLite database contains a field which contains a Date stored as a string in the format 'yyyy-MM-dd HH:mm:ss'. Is it possible to query the database to get the record which contains the most recent date please?
duncanportelli
  • 3,161
  • 8
  • 38
  • 59
76
votes
8 answers

How to use Room Persistence Library with pre-populated database?

I'd like to use Room with a pre-populated database, but I can't understand how to tell Room where to find my database. I've now put it in src/main/assets/databases and when I create the instance for the Room database I create it this…
75
votes
21 answers

android.database.sqlite.SQLiteCantOpenDatabaseException: unknown error (code 14): Could not open database

I have read various on site about this issue but I am not able to figure this out. I am using pre-build database for this app. I am using jellybean for this app. AndroidManifest.xml
user2438323
  • 751
  • 1
  • 6
  • 8
74
votes
2 answers

Will SQLite performance degrade if the database size is greater than 2 gigabytes?

Last year when I checked about SQLite on their web site, the recommended SQLite database size was 2 gigabytes. But now, I could not find that recommendation again. So has anyone tried to work with an SQLite database that is bigger than 2 gigabytes…
Enkhbat
  • 851
  • 1
  • 6
  • 6
70
votes
5 answers

How to perform an SQLite query within an Android application?

I am trying to use this query upon my Android database, but it does not return any data. Am I missing something? SQLiteDatabase db = mDbHelper.getReadableDatabase(); String select = "Select _id, title, title_raw from search Where(title_raw like…
Dennie
  • 2,621
  • 13
  • 42
  • 41
66
votes
10 answers

How to get row count in sqlite using Android?

I am creating task manager. I have tasklist and I want when I click on particular tasklist name if it empty then it goes on Add Task activity but if it has 2 or 3 tasks then it shows me those tasks into it in list form. I am trying to get count in…
Shweta
  • 1,145
  • 5
  • 18
  • 35
66
votes
9 answers

Android SQLite Insert or Update

as can be seen in the documentation the syntax to make insert or update is : INSERT OR REPLACE INTO () VALUES (), my question is there any function that merge the following ? public long insert (String table, String…
Luis Neves
  • 1,067
  • 2
  • 10
  • 21
61
votes
5 answers

Database won't remove when uninstall the Android Application

I have two major questions. Database won't delete when uninstall app. Downloaded files won't delete while unstable the app. There is a database in my android application. I create it by java class as follows. public DataBaseHelper(Context…
KZoNE
  • 1,249
  • 1
  • 16
  • 27
60
votes
10 answers

Android SQLiteOpenHelper: Why onCreate() method is not called?

I am trying to make my first Android app. I noticed that the SQLiteOpenHelper.onCreate() method is not called to create tables if the database not exists. However, the onCreate() method did not work even thought I tried to debug. Please look at the…
zono
  • 8,366
  • 21
  • 75
  • 113
1
2 3
99 100