Skip to main content

Posts

Showing posts with the label sqlite

What "additional configuration" is necessary to reference a .NET 2.0 mixed mode assembly in a .NET 4.0 project?

I have a project in which I'd like to use some of the .NET 4.0 features but a core requirement is that I can use the System.Data.SQLite framework which is compiled against 2.X. I see mention of this being possible such as the accepted answer here but I don't see how to actually achieve this.

Android sqlite get boolean from database

was just wondering, how can I obtain the value of a boolean field in a sqlite database in android? I usually use getString() getInt() etc to get the values of my fields, but there does not seem to be a getBoolean() method. Any takers? Kev Source: Tips4all

Android. Content provider or Database?

Since I've seen a presentation from Google IO I'm a bit confused in the question, if it's better to use content providers or databases. Or it makes no difference if I don't want to share any data with other applications. If I've understood it right, content providers based on SQLite DBs and it's also possible that content of them is only accessable for my application. Can you give some explanations? Thank you very much, Mur Source: Tips4all

Android ContentProvider Performance

I'm curious if anyone has done any performance testing on querying a ContentProvider via ContentResolver vs querying a SQLiteDatabase object in the same process. I'm guessing that a ContentResolver query passes back a Cursor that communicates with the database through a Binder (Android IPC). This means that if I read the contents of 100 records through the Cursor that would result 100 Binder method calls. Are my guesses correct and if so would that be significantly slower than accessing the database in the same process? Source: Tips4all

Add an SQLite database to an iPhone app

I am trying to learn SQLite, and I am building an iPhone app. But I would like to add an SQLite database to my building app. I have got three tutorials, but I am not clear on that code. How can I add an SQLite database to my building app? What would sample code look like? Source: Tips4all

SQLlite Android. Managing data

Hi friends. I'll tell you the aim of this part of my app. I've got a SQLite dB which has 3 columns. First is "Quantity", Second is "Product" and third is "Price". Well, what i want to do is to get the whole dB and send it by email. This is what i have right now: public class Visual extends Activity { TextView tv; Button sqlGetInfo; long l ; long b=1; int c,i; String returnedQuantity ,returnedProduct ,returnedPrice; String[] filas; @Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.visual); tv = (TextView) findViewById(R.id.tvSQLinfo); sqlGetInfo = (Button) findViewById(R.id.EnviarPedido); SQLManager info = new SQLManager(this); info.open(); String data= info.getData(); info.close(); tv.setText(data); Up to here, my code works fine, it displays the data in the textView. Here is the problem. My dB has

SQLlite Android. Managing data

Hi friends. I'll tell you the aim of this part of my app. I've got a SQLite dB which has 3 columns. First is "Quantity", Second is "Product" and third is "Price". Well, what i want to do is to get the whole dB and send it by email. This is what i have right now: public class Visual extends Activity { TextView tv; Button sqlGetInfo; long l ; long b=1; int c,i; String returnedQuantity ,returnedProduct ,returnedPrice; String[] filas; @Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.visual); tv = (TextView) findViewById(R.id.tvSQLinfo); sqlGetInfo = (Button) findViewById(R.id.EnviarPedido); SQLManager info = new SQLManager(this); info.open(); String data= info.getData(); info.close(); tv.setText(data); Up to here, my code works fine, it displays the data in the textView. Here is the problem. My dB has

database insertion working well on android emulator but not on device

I have created a database using this tutorial . When I insert the values in my table, it works on the emulator and I have seen the values are inserted correctly. But when I run my application on a device, it gives me this error: 02-29 17:30:45.341: E/Database(3300):android.database.sqlite.SQLiteException:no such table: recently_used: , while compiling: INSERT INTO recently_used(iconsset_name, icon_name) VALUES(?, ?); 02-29 17:30:45.341: E/Database(3300): at android.database.sqlite.SQLiteCompiledSql.native_compile(Native Method) 02-29 17:30:45.341: E/Database(3300):at android.database.sqlite.SQLiteCompiledSql.compile(SQLiteCompiledSql.java:92) 02-29 17:30:45.341: E/Database(3300):at android.database.sqlite.SQLiteCompiledSql.<init>(SQLiteCompiledSql.java:65) 02-29 17:30:45.341: E/Database(3300): at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:83) 02-29 17:30:45.341: E/Database(3300): at android.database.sqlite.SQLiteStatement.<init> (S

Android database closed exception

I'm working on a project where I'm downloading and saving data from web to sqlite database. A few minutes ago I receive a strange exception to our server from a user which is saying that the sqlite database is already closed..and I just checked the whole file where the exception happened and I'm not calling dbHelper.close(); . Here is the function where the app crashes and LogCat message : public void insertCollectionCountries(JSONObject obj, Context context) { //Insert in collection_countries if(RPCCommunicator.isServiceRunning){ Log.w("","JsonCollection - insertCollectionCountries"); ContentValues valuesCountries = new ContentValues(); try { collectionId = Integer.parseInt(obj.getString("collection_id")); dbHelper.deleteSQL("collection_countries", "collection_id=?", new String[] {Integer.toString(collectionId)}); JSONArray arrayCountries = obj.getJSONArray("

Works fine for the first time, next time getting DB locked issue

Please find the below function.it works fine for the first time. I mean , when i add a text it works for the first time , then when i try to add a new text again , it give me like "DB is locked". I am not sure how it works for the first not again? Please let me know what is the problem in my code. //================================================================== - ( BOOL ) addNewSimpleTemplates:(NSString*)dbPath:(NSString*)title{ //================================================================== BOOL returnVal = NO; NSString *maxValuePosition; if (sqlite3_open([dbPath UTF8String], &database) == SQLITE_OK) { NSString *selectSQL = [NSString stringWithFormat:@"select MAX(pr.position) FROM phrase_reference pr inner join storyboard_main_categories smc on smc.id = pr.main_category_id where smc.category_name = %@", @"'Simple Templates'"]; const char *sql = [selectSQL UTF8String]; sqlite3_stmt *selectStmt; if(sqlite

iPhone: Sqlite update or insert row

I want to update the quantity if the menuid is already available otherwise add a new row. I used the following code.But no row is added or updated. sqlite3 *database; sqlite3_stmt *addStmt=nil; if (selection== nil) { selection =@"Medium"; } if (sqlite3_open([dbPath UTF8String], &database) == SQLITE_OK) { const char *select="select quantity from item where menuid = ?"; sqlite3_stmt *selectstmt; if(sqlite3_prepare_v2(database, select, -1, &selectstmt, NULL) == SQLITE_OK) { while(sqlite3_step(selectstmt) == SQLITE_ROW) { menuID= [NSString stringWithUTF8String:(char *)sqlite3_column_text(selectstmt, 0)]; char *quant = (char *)sqlite3_column_text(selectstmt,1); quantity=[NSString stringWithUTF8String:(char *)quant]; // [self.ids addObject:menuID]; } sqlite3_reset(selectstmt);

Very slow query where table have many records

I' m using sqlite on iphone. I have table with 200 000 records. It' s size is small, only 2 MB. I' m doing standard select(3 collumns) with two simple condtions. I' m operating only on integer values( in return and condtion). All data are unique. I'm get usually only 10-50 records from database. In spite of that my query take 3 sec. It' s a lot of time. How i can improve this ? Edit: I can't load my table with other thread. NSString * query = [ NSString stringWithFormat:@"SELECT rRozklad.hour, rRozklad.minute, rRozklad.marks FROM rRozklad.idOkres=%i AND rRozklad.idPolaczeniaLinie=2 ORDER by rRozklad.hour, rRozklad.minute", okres]; NSLog(@"%@", query); const char * querystring = [ query UTF8String ]; sqlite3_stmt * statment; if(sqlite3_prepare_v2(database, querystring, -1, &statment, nil) == SQLITE_OK){ while(sqlite3_step(statment) == SQLITE_ROW){ NSMutableArray * temp = [[NSMutableArray alloc] initWithCapacity:2];

Running a select from sqllite

I am trying to run a select using sqllite. Its my first time using sqllite and I am getting this error over and over. function ="Adding Event CODE: public List<Example> getExampleByFunctionList(String function) { List<Example> examplelist = new ArrayList<Example>(); String getQuery = "SELECT * FROM " + MySQLiteHelper.TABLE_EXAMPLE+ " where "+ MySQLiteHelper.COLUMN_EXAMPLE_FUNCTION +" = "+""+function+""; Cursor cursor = database.rawQuery(getQuery, null); cursor.moveToFirst(); while (!cursor.isAfterLast()) { Example example = cursorToExample(cursor); examplelist.add(example); cursor.moveToNext(); } cursor.close(); return examplelist; } ERROR: 02-12 12:37:29.218: E/AndroidRuntime(316

Need SQLite3 APIS for iPhone

I need to add some Database stuff in my iPhone application. i know how to use Database methods manually. But i want to prebuilt APIs which allows me to create tables, insert, delete and update records according to my tables. So is there any kind of prebuilt APIS for sqlite3 in Iphone. Please guide me if there is any. Thanks alot.

SQLite and Activity updates

I have a neat, working SQLite database on Android that records species observations. I am then using JSON (successfully) to verify observations entered against a set of parameters on a remote database. On verification, a flag in the database is updated to say that this process has been done. But, when I view my main activity (Text, the values for observations with flags after verification don't update. My activity order is: Main activity (obs = 0 from database) Obs Entry activity Main activity (obs = 1 with flag A from db) Data management activity, verify button Verify done activity, main button Main activity (obs = 1 with flag A from db) If I exit, or leave it for a while, then come back in to Main activity, the database is being polled correctly and obs = 1 with flag B from db. So I know my database is right and the SQL is correct too. Could it be that I'm declaring my buttons at the wrong point for the Activity to correctly resume()? My code

Android SQLite query with &#39;WHERE&#39; selection arguments not working

I have this code: if (idListe.size()>0) { strIdArray = new String[idListe.size()]; idListe.toArray(strIdArray); //my query starts here c = dbHelper.query(true, DataBaseHelper.DB_COURSE, dbHelper.COURSE_TABLE_AUFGABEN, new String[] { dbHelper.COURSE_AUFGABEN_COLUMN_ID, dbHelper.COURSE_AUFGABEN_COLUMN_ADRESSID, dbHelper.COURSE_AUFGABEN_COLUMN_KURSART }, dbHelper.COURSE_AUFGABEN_COLUMN_ID + " = ?",strIdArray, dbHelper.COURSE_AUFGABEN_COLUMN_KURSART, null, dbHelper.COURSE_AUFGABEN_COLUMN_KURSART + " ASC", null); startManagingCursor(c); } And get a this error: 01-15 13:01:27.489: E/AndroidRuntime(703): android.database.sqlite.SQLiteException: bind or column index out of range: handle 0x3fd490 I've tried several combinations and the result always stays the same. If the size of the strIdArray is '1' the