Wrote the following code to insert an item into sqlite database. This
code worked fine in Android 1.6 device but I got an error in Android
2.1 device

    public static final String PROVIDER_NAME = "org.books";
    public static final Uri CONTENT_URI =
      Uri.parse("content://"+ PROVIDER_NAME + "/books");
    private static final String DATABASE_TABLE = "titles";


    public Uri insert(Uri uri, ContentValues values) {
         //---add a new book---
    long rowID = booksDB.insert(
       DATABASE_TABLE, "", values);

    //---if added successfully---
    if (rowID>0)
    {
       Uri _uri = ContentUris.withAppendedId(CONTENT_URI, rowID);
       getContext().getContentResolver().notifyChange(_uri, null);
       return _uri;
    }
    throw new SQLException("Failed to insert row into " + uri);
    }

    ContentValues values = new ContentValues();

              Uri  uri = getContentResolver().insert(
                           Uri.parse(
                              "content://org.books/books"),
                              values);


This is the error I got when running on Android 2.1 device. Is my URL
format correct?


07-22 17:56:59.479: ERROR/AndroidRuntime(4926): Caused by:
java.lang.IllegalArgumentException: Unknown URL content://org.books/books
07-22 17:56:59.479: ERROR/AndroidRuntime(4926):     at
android.content.ContentResolver.insert(ContentResolver.java:626)

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to