Strict Standards: Non-static method utf_normalizer::nfc() should not be called statically in /www/htdocs/w006661d/anddev/includes/utf/utf_tools.php on line 1781
[phpBB Debug] PHP Notice: in file /includes/session.php on line 1007: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/session.php on line 1007: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/session.php on line 1007: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)

Strict Standards: Non-static method utf_normalizer::nfc() should not be called statically in /www/htdocs/w006661d/anddev/includes/utf/utf_tools.php on line 1781
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4362: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4364: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4365: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4366: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
anddev.org • View topic - Problem to query single lines in SQLITE3 with ContentProvide

Problem to query single lines in SQLITE3 with ContentProvide

Problems with WiFi, SQLite ,Bluetooth, WiMax, Proxies, etc...

Problem to query single lines in SQLITE3 with ContentProvide

Postby thomacco » Mon Jun 02, 2008 9:52 am

Hi,

I am new in Android and tried to make my own ContentProvider.

I can now insert rows and I can delete,update and query a whole Table.

Now I wanted to implement to query a single row of a table with its _id and I stucked at this problem.

In my Test-Program I query the row with the _id = 1 with this code:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. String[] projection = new String[]{
  2.                                 Dates.DB_entry._ID,
  3.                                 Dates.DB_entry.TITLE                           
  4.                 };
  5.                 Uri uri_id = Dates.DB_entry.CONTENT_URI;
  6.                 String number = new String();
  7.                 number = number.valueOf(1);
  8.                 uri_id = uri_id.withAppendedPath(Dates.DB_entry.CONTENT_URI, number);
  9.                
  10.                 Cursor c = managedQuery(uri_id, projection, null, null);
  11.  
Parsed in 0.011 seconds, using GeSHi 1.0.8.4


Then, the program jumps into the query-function of the ContentProvider, which looks like that:




Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. @Override
  2.         public Cursor query (Uri  url, String[] projection, String selection, String[] selectionArgs, String sort)
  3.         {
  4.                 SQLiteQueryBuilder qb = new SQLiteQueryBuilder();
  5.        
  6.                
  7.                 int i = URL_MATCHER.match(url);
  8.                 switch(URL_MATCHER.match(url))
  9.                 {
  10.                 case ENTRY_ID:
  11.                         //qb.setTables("Termin");
  12.                         qb.appendWhere("_id="+ "=" + ContentUris.parseId(url));
  13.                        
  14.                
  15.                 case ENTRIES:                                                                   //Alle Dates ausgeben
  16.                         qb.setTables("Termin");
  17.                         qb.setProjectionMap(DATES_LIST_PROJECTION_MAP);
  18.                         break;
  19.                        
  20.                 case VAR_ID:
  21.                         //qb.setTables("Vars");
  22.                         qb.appendWhere("(_id="+ "=" + ContentUris.parseId(url));
  23.            
  24.                 case VARS:                                                                      //Alle Dates ausgeben
  25.                         qb.setTables("Vars");
  26.                         qb.setProjectionMap(VAR_LIST_PROJECTION_MAP);
  27.                         break;
  28.            
  29.                 default:                                                                        //ungültige URI
  30.                         throw new IllegalArgumentException("Unknown URL " + url);
  31.                 }
  32.                
  33.                  // If no sort order is specified use the default
  34.         String orderBy;
  35.         if (TextUtils.isEmpty(sort))
  36.         {
  37.             orderBy = Dates.DB_Variablen.DEFAULT_SORT_ORDER;
  38.         } else
  39.         {
  40.             orderBy = sort;
  41.         }
  42.        
  43.                 String s = qb.buildQuery(projection, selection, selectionArgs, null, null, null);
  44.                 Cursor c = qb.query(mDB, projection, selection, selectionArgs, null, null, null);
  45.                 c.setNotificationUri(getContext().getContentResolver(), url);
  46.                 return c;
  47.         }
  48.  
Parsed in 0.012 seconds, using GeSHi 1.0.8.4


The program then gets in the case ENTRIES_ID and does everything, then it used to be.
After that the String s, which I only implemented for testing, is "SELECT _id,title FROM Termin WHERE (_id==1)" which looks good for me. When I query this String with SQlite3 in the console i also get this row as a result.

But when I start the qb.query, I get the error-message

Application Error: swt2.db

An error has occured in swt2.db. near ")": syntax error, while compiling:
SELECT COUNT(*) FROM (SELECT _id, title FROM Termin WHERE (_id==1))).


Can someone please tell me, why the compiler extends the SQL-Query with "SELECT COUNT(.....)) and how I can solve these problems.

Thanks a lot
thomacco
thomacco
Once Poster
Once Poster
 
Posts: 1
Joined: Sun May 25, 2008 4:55 pm

Top

Return to Networking & Database Problems

Who is online

Users browsing this forum: No registered users and 4 guests