android-sqlite

SQLite - Any difference between table-constraint UNIQUE & column-constraint UNIQUE?

ぃ、小莉子 提交于 2020-01-01 12:21:16
问题 Question about SQLite. In the CREATE TABLE SQL, we can add UNIQUE constraints in either way: column-constraint or table-constraint. My question is simple. Do they work differently? The only difference I could find was, in table-constraint, there could be multiple indexed-column s in a single constraint. Column-constraint: Table-constraint: Here is an example: CREATE TABLE Example ( _id INTEGER PRIMARY KEY, name TEXT UNIQUE ON CONFLICT REPLACE, score INTEGER ) and CREATE TABLE Example ( _id

SQLite - Any difference between table-constraint UNIQUE & column-constraint UNIQUE?

送分小仙女□ 提交于 2020-01-01 12:21:07
问题 Question about SQLite. In the CREATE TABLE SQL, we can add UNIQUE constraints in either way: column-constraint or table-constraint. My question is simple. Do they work differently? The only difference I could find was, in table-constraint, there could be multiple indexed-column s in a single constraint. Column-constraint: Table-constraint: Here is an example: CREATE TABLE Example ( _id INTEGER PRIMARY KEY, name TEXT UNIQUE ON CONFLICT REPLACE, score INTEGER ) and CREATE TABLE Example ( _id

SQLite database in combination with fragments

我怕爱的太早我们不能终老 提交于 2020-01-01 05:42:20
问题 I'm changing my application from Activity's to Fragments, it's going great but I've one bug that won't let me open my database. Here's the error (from the logcat): 05-17 15:28:38.704 13025-13025/com.MJV.werktijden E/AndroidRuntime: FATAL EXCEPTION: main java.lang.NullPointerException at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:224) at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:164) at com.MJV.werktijden.DBAdapter

Use Firebase DB with local DB

徘徊边缘 提交于 2020-01-01 05:17:40
问题 In my app I have SQLite db . I want to introduce sync between devices of my users. Firebase DB looks like an acceptable solution, but Firebase DB is cloud db at first. So, I can't use it as local db if user will reject auth dialog and let him use app, but without cloud-sync. Now I think about combining my local SQLite db with cloud Firebase db . For example, when user adds new row to local SQLite db , my app will also put data into Firebase DB . Other devices of this user will catch this

SQLiteException: table already exists

百般思念 提交于 2020-01-01 02:41:09
问题 I added to my DB the table called "MEDIA_TABLE" and i got the following error code: 05-15 20:56:22.976: E/AndroidRuntime(5968): android.database.sqlite.SQLiteException: table personal_stats already exists (code 1): , while compiling: CREATE TABLE personal_stats (_id INTEGER PRIMARY KEY AUTOINCREMENT, pictures TEXT, videos TEXT); My second table works fine. i tried to uninstall my app and install it and it wont work, maybe there is a limit of tables in DB? Here is my onCreate code: @Override

How to translate the PostgreSQL array_agg function to SQLite?

人走茶凉 提交于 2019-12-30 08:29:28
问题 This query works in PostgreSQL: Select ot.MCode,array_to_string(array_agg(tk1.TName || ',' || ot.TTime), ' - ') as oujyu_name_list From TR_A ot inner join MS_B tk1 on ot.Code = tk1.Code Where ot.Code in (Select Code From TR_C ) Group byot.MCode but it does not work in SQLite, because SQLite does not have the array_agg() function. How can this query be converted to SQLite? 回答1: For this query, you can use group_concat, which directly returns a string: SELECT ..., group_concat(tk1.TName || ','

How to use images in Android SQLite that are larger than the limitations of a CursorWindow?

﹥>﹥吖頭↗ 提交于 2019-12-28 02:19:04
问题 As per the question. Say I have an Image that is approx 3.5 MB in size, which could be saved as a blob, but couldn't be retrieved due to the 2Mb limitation of a CursorWindow? Note The question has been asked purely to show, contrary to responses saying that it cannot be done, that it can be done (albeit NOT RECOMMENDED ), as this is a It’s OK to Ask and Answer Your Own Questions. 回答1: Note This is not recommended as it would still likely be quite inefficient in comparison to storing the path

Attempt to reopen an already-closed object sqlitedatabase

流过昼夜 提交于 2019-12-28 02:12:27
问题 I have a databaseHandler. I need to count the rows in table. App crashes by this error: android attempt to reopen an already-closed object sqlitedatabase . I simply use this code in activity: db.getContactsCount(); But app crashes. Furthemore I want to reset the tables (delete table rows). I added the method below: public void deleteTable() { SQLiteDatabase db = this.getWritableDatabase(); db.delete("contacts", null, null); } It works good but I can't use this one: @Override public void

ListView is not shows the correct images that are in the drawable according to their name in sqlite

僤鯓⒐⒋嵵緔 提交于 2019-12-25 18:26:15
问题 I have an android application that use sqlite as DB and fetch data from DB then display these data in the ListView . The problem is that it is not display the correct images according to their names in the sqlite database so how to fix this error? can anyone help me? CustomAdapterMatchSchedule.java @Override public View getView(int position, View convertView, ViewGroup arg2) { // TODO Auto-generated method stub ItemDetails itemdetail = itemdetailsList.get(position); if (convertView == null) {

How to delete a particular row from SQLite database

久未见 提交于 2019-12-25 16:45:13
问题 I have created a list view. On button click the data is added in list and also stored in an SQLite database. I have also added the image on the right-hand side of list, on click of which a particular row data is deleted, but I also want to delete data from SQLite. How could I do this? Main Activity.Java public class MainActivity extends Activity { EditText editText; Button Button,Button1; ListView listView; ArrayList<String> listItems; BaseAdapter adapter; private DataBaseHandler mHelper;