本文介绍了如何从android中的Cursor获取图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想从光标处获取图像。我正在使用Mediastor.image.data
这是我的代码
i want to get the images from the cursor . i am using Mediastor.image.datahere is my code
String los=getArguments().getString(ARG_SECTION_NUMBER1);
Uri mImageUri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI;
final String[] columns = { MediaStore.Images.Media.DATA, MediaStore.Images.Media.DATE_ADDED};
ContentResolver mContentResolver = rootView.getContext().getContentResolver();
Cursor mCursor = mContentResolver.query(mImageUri, columns, MediaStore.Images.Media.DATA + " like ? ",new String[] {los}, null);
推荐答案
///您的UserContract类
//your UserContract class
public class UserContract {
public static abstract class NewUserInfo
{
public static final String IMAGE = "image";
}}
//在您的dbhelper类中
//In your dbhelper class
public DataProvider getInformations()
{
ArrayList<DataProvider> ListViewValuesArr = new ArrayList<DataProvider>();
SQLiteDatabase db = this.getReadableDatabase();
Cursor res = db.rawQuery( "select " +UserContract.NewUserInfo.IMAGE+" from "+UserContract.NewUserInfo.TABLE_NAME, null );
res.moveToFirst();
DataProvider dataProvider = new DataProvider();
while(res.isAfterLast() == false){
dataProvider.setImage(res.getString(res.getColumnIndex(UserContract.NewUserInfo.IMAGE)));
res.moveToNext();
}
db.close();
return dataProvider;
}
//在您的活动中
Context context = this;
UserDbHelper userDbHelper;
SQLiteDatabase sqLiteDatabase;
Cursor cursor;
String image;
@Override
protected void onCreate(Bundle savedInstanceState) {
userDbHelper =new UserDbHelper(this);
DataProvider dataProvider=userDbHelper.getInformations();
image = dataProvider.getImage();
}
这篇关于如何从android中的Cursor获取图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!