lundi 26 janvier 2015

Android Database Content Provider Save Error

I have made a database with content provider and when I try to save the content it gives this error.


This is my LogCat.


01-26 06:23:38.451 1309-1309/com.tubapps.georgezoiade.databaseapp I/dalvikvm﹕ Could not find method android.view.ViewGroup.onNestedScrollAccepted, referenced from method android.support.v7.internal.widget.ActionBarOverlayLayout.onNestedScrollAccepted 01-26 06:23:38.451 1309-1309/com.tubapps.georgezoiade.databaseapp W/dalvikvm﹕ VFY: unable to resolve virtual method 11514: Landroid/view/ViewGroup;.onNestedScrollAccepted (Landroid/view/View;Landroid/view/View;I)V 01-26 06:23:38.461 1309-1309/com.tubapps.georgezoiade.databaseapp D/dalvikvm﹕ VFY: replacing opcode 0x6f at 0x0000 01-26 06:23:38.461 1309-1309/com.tubapps.georgezoiade.databaseapp I/dalvikvm﹕ Could not find method android.view.ViewGroup.onStopNestedScroll, referenced from method android.support.v7.internal.widget.ActionBarOverlayLayout.onStopNestedScroll 01-26 06:23:38.461 1309-1309/com.tubapps.georgezoiade.databaseapp W/dalvikvm﹕ VFY: unable to resolve virtual method 11520: Landroid/view/ViewGroup;.onStopNestedScroll (Landroid/view/View;)V 01-26 06:23:38.471 1309-1309/com.tubapps.georgezoiade.databaseapp D/dalvikvm﹕ VFY: replacing opcode 0x6f at 0x0000 01-26 06:23:38.481 1309-1309/com.tubapps.georgezoiade.databaseapp I/dalvikvm﹕ Could not find method android.support.v7.internal.widget.ActionBarOverlayLayout.stopNestedScroll, referenced from method android.support.v7.internal.widget.ActionBarOverlayLayout.setHideOnContentScrollEnabled 01-26 06:23:38.481 1309-1309/com.tubapps.georgezoiade.databaseapp W/dalvikvm﹕ VFY: unable to resolve virtual method 9080: Landroid/support/v7/internal/widget/ActionBarOverlayLayout;.stopNestedScroll ()V 01-26 06:23:38.491 1309-1309/com.tubapps.georgezoiade.databaseapp D/dalvikvm﹕ VFY: replacing opcode 0x6e at 0x000e 01-26 06:23:38.752 1309-1309/com.tubapps.georgezoiade.databaseapp I/dalvikvm﹕ Could not find method android.view.ViewGroup.onRtlPropertiesChanged, referenced from method android.support.v7.widget.Toolbar.onRtlPropertiesChanged 01-26 06:23:38.752 1309-1309/com.tubapps.georgezoiade.databaseapp W/dalvikvm﹕ VFY: unable to resolve virtual method 11517: Landroid/view/ViewGroup;.onRtlPropertiesChanged (I)V 01-26 06:23:38.752 1309-1309/com.tubapps.georgezoiade.databaseapp D/dalvikvm﹕ VFY: replacing opcode 0x6f at 0x0007 01-26 06:23:38.791 1309-1309/com.tubapps.georgezoiade.databaseapp I/dalvikvm﹕ Could not find method android.content.res.TypedArray.getChangingConfigurations, referenced from method android.support.v7.internal.widget.TintTypedArray.getChangingConfigurations 01-26 06:23:38.791 1309-1309/com.tubapps.georgezoiade.databaseapp W/dalvikvm﹕ VFY: unable to resolve virtual method 380: Landroid/content/res/TypedArray;.getChangingConfigurations ()I 01-26 06:23:38.801 1309-1309/com.tubapps.georgezoiade.databaseapp D/dalvikvm﹕ VFY: replacing opcode 0x6e at 0x0002 01-26 06:23:38.811 1309-1309/com.tubapps.georgezoiade.databaseapp I/dalvikvm﹕ Could not find method android.content.res.TypedArray.getType, referenced from method android.support.v7.internal.widget.TintTypedArray.getType 01-26 06:23:38.811 1309-1309/com.tubapps.georgezoiade.databaseapp W/dalvikvm﹕ VFY: unable to resolve virtual method 402: Landroid/content/res/TypedArray;.getType (I)I 01-26 06:23:38.811 1309-1309/com.tubapps.georgezoiade.databaseapp D/dalvikvm﹕ VFY: replacing opcode 0x6e at 0x0002 01-26 06:23:39.141 1309-1322/com.tubapps.georgezoiade.databaseapp E/ActivityThread﹕ Failed to find provider info for com.tubapps.georgezoiade.databaseapp.contentprovider 01-26 06:23:39.181 1309-1323/com.tubapps.georgezoiade.databaseapp E/ActivityThread﹕ Failed to find provider info for com.tubapps.georgezoiade.databaseapp.contentprovider 01-26 06:23:39.471 1309-1309/com.tubapps.georgezoiade.databaseapp I/Choreographer﹕ Skipped 39 frames! The application may be doing too much work on its main thread. 01-26 06:23:39.667 1309-1309/com.tubapps.georgezoiade.databaseapp D/gralloc_goldfish﹕ Emulator without GPU emulation detected. 01-26 06:23:40.841 1309-1313/com.tubapps.georgezoiade.databaseapp D/dalvikvm﹕ GC_CONCURRENT freed 221K, 4% free 8222K/8519K, paused 53ms+21ms, total 385ms 01-26 06:23:40.971 1309-1309/com.tubapps.georgezoiade.databaseapp I/Choreographer﹕ Skipped 206 frames! The application may be doing too much work on its main thread. 01-26 06:23:43.842 1309-1309/com.tubapps.georgezoiade.databaseapp I/Choreographer﹕ Skipped 43 frames! The application may be doing too much work on its main thread. 01-26 06:23:47.032 1309-1309/com.tubapps.georgezoiade.databaseapp D/dalvikvm﹕ GREF has increased to 201 01-26 06:23:47.621 1309-1309/com.tubapps.georgezoiade.databaseapp I/Choreographer﹕ Skipped 125 frames! The application may be doing too much work on its main thread. 01-26 06:23:48.262 1309-1309/com.tubapps.georgezoiade.databaseapp I/Choreographer﹕ Skipped 33 frames! The application may be doing too much work on its main thread. 01-26 06:23:50.522 1309-1309/com.tubapps.georgezoiade.databaseapp I/Choreographer﹕ Skipped 63 frames! The application may be doing too much work on its main thread. 01-26 06:23:51.021 1309-1309/com.tubapps.georgezoiade.databaseapp I/Choreographer﹕ Skipped 40 frames! The application may be doing too much work on its main thread. 01-26 06:23:51.281 1309-1309/com.tubapps.georgezoiade.databaseapp I/Choreographer﹕ Skipped 47 frames! The application may be doing too much work on its main thread. 01-26 06:23:52.491 1309-1313/com.tubapps.georgezoiade.databaseapp D/dalvikvm﹕ GC_CONCURRENT freed 163K, 4% free 8509K/8775K, paused 21ms+33ms, total 189ms 01-26 06:23:53.001 1309-1309/com.tubapps.georgezoiade.databaseapp I/Choreographer﹕ Skipped 170 frames! The application may be doing too much work on its main thread. 01-26 06:23:53.191 1309-1309/com.tubapps.georgezoiade.databaseapp I/Choreographer﹕ Skipped 32 frames! The application may be doing too much work on its main thread. 01-26 06:24:14.711 1309-1309/com.tubapps.georgezoiade.databaseapp I/Choreographer﹕ Skipped 94 frames! The application may be doing too much work on its main thread. 01-26 06:24:20.332 1309-1309/com.tubapps.georgezoiade.databaseapp E/ActivityThread﹕ Failed to find provider info for com.tubapps.georgezoiade.databaseapp.contentprovider 01-26 06:24:20.332 1309-1309/com.tubapps.georgezoiade.databaseapp D/AndroidRuntime﹕ Shutting down VM 01-26 06:24:20.332 1309-1309/com.tubapps.georgezoiade.databaseapp W/dalvikvm﹕ threadid=1: thread exiting with uncaught exception (group=0x40a13300) 01-26 06:24:20.362 1309-1309/com.tubapps.georgezoiade.databaseapp E/AndroidRuntime﹕ FATAL EXCEPTION: main java.lang.IllegalArgumentException: Unknown URL content://com.tubapps.georgezoiade.databaseapp.contentprovider/incomes at android.content.ContentResolver.insert(ContentResolver.java:860) at com.tubapps.georgezoiade.databaseapp.IncomeEdit.onClick(IncomeEdit.java:128) at android.view.View.performClick(View.java:4084) at android.view.View$PerformClick.run(View.java:16966) at android.os.Handler.handleCallback(Handler.java:615) at android.os.Handler.dispatchMessage(Handler.java:92) at android.os.Looper.loop(Looper.java:137) at android.app.ActivityThread.main(ActivityThread.java:4745) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:511) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553) at dalvik.system.NativeStart.main(Native Method) 01-26 06:24:22.861 1309-1309/com.tubapps.georgezoiade.databaseapp I/Process﹕ Sending signal. PID: 1309 SIG: 9


And this is MyContentProvider Class.


public class MyContentProvider extends ContentProvider{



private MyDatabaseHelper dbHelper;

private static final int ALL_INCOMES = 1;
private static final int SINGLE_INCOME = 2;

// authority is the symbolic name of your provider
// To avoid conflicts with other providers, you should use
// Internet domain ownership (in reverse) as the basis of your provider authority.
private static final String AUTHORITY = "com.tubapps.georgezoiade.databaseapp.contentprovider";

// create content URIs from the authority by appending path to database table
public static final Uri CONTENT_URI =
Uri.parse("content://" + AUTHORITY + "/incomes");

// a content URI pattern matches content URIs using wildcard characters:
// *: Matches a string of any valid characters of any length.
// #: Matches a string of numeric characters of any length.
private static final UriMatcher uriMatcher;
static {
uriMatcher = new UriMatcher(UriMatcher.NO_MATCH);
uriMatcher.addURI(AUTHORITY, "incomes", ALL_INCOMES);
uriMatcher.addURI(AUTHORITY, "incomes/#", SINGLE_INCOME);
}

// system calls onCreate() when it starts up the provider.
@Override
public boolean onCreate() {
// get access to the database helper
dbHelper = new MyDatabaseHelper(getContext());
return false;
}

//Return the MIME type corresponding to a content URI
@Override
public String getType(Uri uri) {

switch (uriMatcher.match(uri)) {
case ALL_INCOMES:
return "http://ift.tt/1C6SAjx";
case SINGLE_INCOME:
return "http://ift.tt/1EMp00O";
default:
throw new IllegalArgumentException("Unsupported URI: " + uri);
}
}

// The insert() method adds a new row to the appropriate table, using the values
// in the ContentValues argument. If a column name is not in the ContentValues argument,
// you may want to provide a default value for it either in your provider code or in
// your database schema.
@Override
public Uri insert(Uri uri, ContentValues values) {

SQLiteDatabase db = dbHelper.getWritableDatabase();
switch (uriMatcher.match(uri)) {
case ALL_INCOMES:
//do nothing
break;
default:
throw new IllegalArgumentException("Unsupported URI: " + uri);
}
long id = db.insert(IncomeDB.SQLITE_TABLE, null, values);
getContext().getContentResolver().notifyChange(uri, null);
return Uri.parse(CONTENT_URI + "/" + id);
}

// The query() method must return a Cursor object, or if it fails,
// throw an Exception. If you are using an SQLite database as your data storage,
// you can simply return the Cursor returned by one of the query() methods of the
// SQLiteDatabase class. If the query does not match any rows, you should return a
// Cursor instance whose getCount() method returns 0. You should return null only
// if an internal error occurred during the query process.
@Override
public Cursor query(Uri uri, String[] projection, String selection,
String[] selectionArgs, String sortOrder) {

SQLiteDatabase db = dbHelper.getWritableDatabase();
SQLiteQueryBuilder queryBuilder = new SQLiteQueryBuilder();
queryBuilder.setTables(IncomeDB.SQLITE_TABLE);

switch (uriMatcher.match(uri)) {
case ALL_INCOMES:
//do nothing
break;
case SINGLE_INCOME:
String id = uri.getPathSegments().get(1);
queryBuilder.appendWhere(IncomeDB.KEY_ROWID + "=" + id);
break;
default:
throw new IllegalArgumentException("Unsupported URI: " + uri);
}

Cursor cursor = queryBuilder.query(db, projection, selection,
selectionArgs, null, null, sortOrder);
return cursor;

}

// The delete() method deletes rows based on the seletion or if an id is
// provided then it deleted a single row. The methods returns the numbers
// of records delete from the database. If you choose not to delete the data
// physically then just update a flag here.
@Override
public int delete(Uri uri, String selection, String[] selectionArgs) {

SQLiteDatabase db = dbHelper.getWritableDatabase();
switch (uriMatcher.match(uri)) {
case ALL_INCOMES:
//do nothing
break;
case SINGLE_INCOME:
String id = uri.getPathSegments().get(1);
selection = IncomeDB.KEY_ROWID + "=" + id
+ (!TextUtils.isEmpty(selection) ?
" AND (" + selection + ')' : "");
break;
default:
throw new IllegalArgumentException("Unsupported URI: " + uri);
}
int deleteCount = db.delete(IncomeDB.SQLITE_TABLE, selection, selectionArgs);
getContext().getContentResolver().notifyChange(uri, null);
return deleteCount;
}

// The update method() is same as delete() which updates multiple rows
// based on the selection or a single row if the row id is provided. The
// update method returns the number of updated rows.
@Override
public int update(Uri uri, ContentValues values, String selection,
String[] selectionArgs) {
SQLiteDatabase db = dbHelper.getWritableDatabase();
switch (uriMatcher.match(uri)) {
case ALL_INCOMES:
//do nothing
break;
case SINGLE_INCOME:
String id = uri.getPathSegments().get(1);
selection = IncomeDB.KEY_ROWID + "=" + id
+ (!TextUtils.isEmpty(selection) ?
" AND (" + selection + ')' : "");
break;
default:
throw new IllegalArgumentException("Unsupported URI: " + uri);
}
int updateCount = db.update(IncomeDB.SQLITE_TABLE, values, selection, selectionArgs);
getContext().getContentResolver().notifyChange(uri, null);
return updateCount;
}


}


Aucun commentaire:

Enregistrer un commentaire