1.首先获取图片路径
通过getUriFromDrawableRes方法获取
public Uri getUriFromDrawableRes(Context context, int id) {
Resources resources =
context.getResources();
String path =
ContentResolver.SCHEME_ANDROID_RESOURCE + "://"
+
resources.getResourcePackageName(id) + "/"
+
resources.getResourceTypeName(id) + "/"
+
resources.getResourceEntryName(id);
return (Uri) Uri.parse(path);
}
2.将图片传入数据库
String
[]a={"橙汁","android.resource://com.example.chaxun/drawable/ic_launcher"};
arg0.execSQL(insertTable, a);
3.取出数据库的路径
SQLiteDatabase sd = null;
sd =
cx.getWritableDatabase();//获取一个可写的数据库
String sel = "select * from chaxun where
name='橙汁'";//准备SQL语句</