android-sqlite

Is it really necessary to create SQLite tables every time the application starts?

半世苍凉 提交于 2019-12-21 02:42:04
问题 I've noticed in more than one SQLite tutorial that the table is recreated in the onCreate() event of the class that extends SQLiteOpenHelper . I've already created my SQLite database and tables outside the Android environment (Eclipse IDE) with the help of a Firefox add-in. The database tables reside in the expected spot: C:\aXX3&Space\Android\workspace\OnDemandAndAutomatic_Project\assets It seems bizarre to me that I would have to recreate them programmatically each time (obviously, they

Android SQLite query where column is not null and not empty

落花浮王杯 提交于 2019-12-20 12:28:13
问题 I cannot figure out the syntax for the .query call. I need to select all records that match a certain column that do not have a null or empty value for a second (different) column my best attempt: Cursor cursor = mDatabase.query(DatabaseOpenHelper.TABLE_ROOMS, mAllColumns, DatabaseOpenHelper.KEY_ROOM_HOSPITAL_ID + " =? AND " + DatabaseOpenHelper.KEY_ISO + " IS NOT NULL OR NOT ?", new String[]{String.valueOf(hospitalId), ""}, null, null, null); This is returning ALL records. If I use AND in

Putting cursor data into an array

痞子三分冷 提交于 2019-12-20 10:55:38
问题 Being new in Android, I am having trouble dealing with the following: public String[] getContacts(){ Cursor cursor = getReadableDatabase().rawQuery("SELECT name FROM contacts", null); String [] names = {""}; for(int i = 0; i < cursor.getCount(); i ++){ names[i] = cursor.getString(i); } cursor.close(); return names; } The following gives me the following error: 09-18 10:07:38.616: E/AndroidRuntime(28165): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example

How to develop an offline-first native Android app

耗尽温柔 提交于 2019-12-20 10:42:47
问题 We are developing a native Android app (iOS and web to follow) where users can collaboratively create an album. We want as seamless as possible experience when device is not able to connect with server. Something like mentioned in this Hoodie blog but Hoodie is right now for Web and iOS and we are looking for Android right now. Problem Maintaining data of albums, friends, pictures (URL/local, not Bitmap) on Client side. Being able to sync offline create/update operations to server at later

How to improve performance for SQLite database for android

僤鯓⒐⒋嵵緔 提交于 2019-12-20 10:37:50
问题 There are few questions related to this topic on stackoverflow, But I didn't get the proper answer. I have some doubts on performance of flat files, Is it better to use flat files instead of SQLite ? I took performance statistics for Android SQLite . I have performance statistics for one table which have 21 columns Can anybody please suggest how to reduce this insertion time. Records Write time in ms Read time in ms 1000 67813 608 1000 66340 604 1000 64359 609 10000 679837 5159 10000 618062

delete sqlite database when updating new version of application

蓝咒 提交于 2019-12-20 10:27:42
问题 I have uploaded an apk (version 1.0) with 22 tables in SQLite Database on Google Playstore. Now i want to update database with 36 tables in new version (version 2.0) of application. I am storing datebase at default location so when i press "Clear data" in Application Manager , database is gonna deleted. I just want to know how to delete old database (same as clear data) when user update new version? Update: If is there any solution for clear data while updating application from play store

Display SQLite data in RecyclerView

不打扰是莪最后的温柔 提交于 2019-12-20 10:10:36
问题 I search a lot, but I didn't find any step-by-step guides on how to display SQLite data in RecyclerView. Can anyone explain to me how can I do this? My DataBaseAdapter : public class DataBaseAdapter { DataBaseHelper helper; public DataBaseAdapter(Context context) { helper = new DataBaseHelper(context); } public long insertData(String name, String card, String code) { SQLiteDatabase db = helper.getWritableDatabase(); ContentValues contentValues = new ContentValues(); contentValues.put

SQLite Query Exception Android Studio Syntax Error code 1

夙愿已清 提交于 2019-12-20 07:49:00
问题 So im trying to build a search method for my android app and i keep running into this error android.database.sqlite.SQLiteException: near "Prefect": syntax error (code 1): while compiling: SELECT * FROM Person WHERE name = Ford Prefect This is the method i have that is running the query public Cursor findUser(String uName) { Cursor res = myDatabase.query("Person WHERE name = "+uName+"", null,null,null,null,null,null); return res; } And the String uName comes from this method public void

How to set each item retrieved from SQLite database into a Textview of it's own

别等时光非礼了梦想. 提交于 2019-12-20 07:46:30
问题 For now, I have a database with a single table having a single column of type TEXT. I want to be able to retrieve the data from that table and for each string from the table I want to insert it into it's own TextView. I want the TextViews to be arranged in vertical LinearLayout fashion. I know retrieved data is presented in an activity using ListView but I want separate TextView for each because I later want to set each TextView clickable and give each one some function. Please help me with

copying database file from /assets to /data/data folder in file explorer - Android

旧街凉风 提交于 2019-12-20 07:44:10
问题 I have issues in copying database file from /assets to /data/data folder in file explorer. I have searched this website, found many answers, but could not find the appropriate answer that suits my context. I have created the database externally with SQLite Manager and imported it into assets folder. Now, when I run my application, I am getting NullPointerException in the emulator. I found that the package has not created in /data/data folder at all. But the application is launching in the