以下是我的尝试:
@Override
public void onCreate(sqliteDatabase db) {
// Todo Auto-generated method stub
db.execsql("CREATE TABLE" + MP_TABLE_NAME + " ( " +
BaseColumns._ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " +
" NAME TEXT, " +
" LAT REAL, "+
" LNG REAL,"+
");"
);
}
解决方法:
尝试这个..
使用BLOB列创建表:
CREATE TABLE storedImages (_id INTEGER PRIMARY KEY, myImage BLOB);
使用HTTP下载图像并将其存储在表中:
DefaultHttpClient mHttpClient = new DefaultHttpClient();
HttpGet mHttpGet = new HttpGet("your image url");
HttpResponse mHttpResponse = mHttpClient.execute(mHttpGet);
if (mHttpResponse.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
httpentity entity = mHttpResponse.getEntity();
if (entity != null) {
// insert to database
ContentValues values = new ContentValues();
values.put(MyBaseColumn.MyTable.ImageField, EntityUtils.toByteArray(entity));
getContentResolver().insert(MyBaseColumn.MyTable.CONTENT_URI, values);
}
}
将BLOB加载到ImageView中:
ImageView myImage = (ImageView) findViewById(R.id.myImage);
byte[] bb = cursor.getBlob(cursor.getColumnIndex(MyBaseColumn.MyTable.ImageField));
myImage.setimageBitmap(BitmapFactory.decodeByteArray(bb, 0, bb.length));
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。