hello,
Thanks for help.
Actually i have to make an application in that,
i have to fetch all images from phone and display it in thumbnail. So
m trying to fetch all images first. but when i use yr code of example
List8 then also i get an errors. And also i tried yr code that is
asked by Mr.MALIN to you in this post using Content Provider. but not
succeed. as i am very new to Android i have some confusions.
1. If i use Content Provider then it will fetch all images from phone
or from database if i use Content URI like:-content://media/internal/
images.
2. I get an error in,
ContentURI(android.provider.MediaStore.Images.Thumbnails.EXTERNAL_CONTENT_URI.toURI());
error:->The method toURI is undefined for the type Uri.
3. I get an erroe in,
int imageIndex =
cur.getColumnIndex(android.provider.MediaStore.Images.Media.DATA);
if(imageIndex==0)
{
final String tag2="Niketa";
Log.i(tag2,"No files are there");
}
error:->The method getColumnIndex(String) for the type cursor is
deprecated.
my Code is:->
public class ImageCursor extends Activity {
/** Called when the activity is first created. */
public void onCreate(Bundle icicle) {
final String TAG2 = "TAG2";
Log.v(TAG2, "Start" );
getDataImage();
super.onCreate(icicle);
}
public void addImageB(){
ContentValues values = new ContentValues();
values.put(Images.Media.NAME, "road_trip_1");
values.put(Images.Media.DESCRIPTION, "Day 1, trip to Los
Angeles");
ContentURI uri =
getContentResolver().insert(Images.Media.EXTERNAL_CONTENT_URI,
values);
OutputStream outStream;
try {
outStream =
getContentResolver().openOutputStream(uri);
Bitmap sourceBitmap =
BitmapFactory.decodeResource(this.getResources(),
R.drawable.gallery_photo_3);
sourceBitmap.compress(Bitmap.CompressFormat.PNG, 50, outStream);
outStream.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
Log.e("MYAPP>>>>", e.getMessage());
} catch (IOException e) {
e.printStackTrace();
Log.e("MYAPP>>>>", e.getMessage());
}
}
public void getDataImage(){
ContentURI uri = new
ContentURI(android.provider.MediaStore.Images.Thumbnails.EXTERNAL_CONTENT_URI.toURI());
Cursor cur = this.managedQuery(uri, null, null, null);
final String tag2="Niketa";
Log.i(tag2,"NUM");
if(cur != null)
getColumnDataImage(cur);
}
private void getColumnDataImage(Cursor cur){
// if(!cur.first())
// return;
cur.moveToFirst();
int imageIndex =
cur.getColumnIndex(android.provider.MediaStore.Images.Media.DATA);
if(imageIndex==0)
{
final String tag2="Niketa";
Log.i(tag2,"No files are there");
}
else
{
final String tag2="Niketa";
Log.i(tag2,"files ");
}
/* do {
ContentURI imagePath = null;
String u = cur.getString(imageIndex);
Log.i("MYAPP>>>>", ""+u);
if(u!=null){
try {
imagePath = new
ContentURI(u);
} catch (URISyntaxException e) {
e.printStackTrace();
Log.e("MYAPP>>>>",
e.getMessage());
}
Log.i("MYAPP>>>>",
""+imagePath.toString());
if(imagePath != null){
InputStream is = null;
ContentResolver cr =
this.getContentResolver();
if(cr != null){
try{
is =
cr.openInputStream(imagePath);
} catch
(FileNotFoundException e) {
e.printStackTrace();
Log.e("MYAPP>>>>", e.getMessage());
}
}
if(is != null){
b =
BitmapFactory.decodeStream(is);
}
}
}
}while (cur.next());*/
}
}
Please tell what to do and HOW. Please Do help As soon as possible.
Thanks.
On Sep 18, 11:55 pm, "Megha Joshi" <[EMAIL PROTECTED]> wrote:
> Check out the sample code for ListView with Photos and ListView with
> checkboxes at ApiDemos/Views/Lists/Single choice list,
> ApiDemos/Views/Lists/Photos.
> Perhaps you can merge the two to display images in list format with
> checkbox.
>
> 2008/9/18 Pratik Goswami <[EMAIL PROTECTED]>
>
>
>
> > Hello friends.
> > I have to develop an application in which user can upload to their
> > photos to social networks. But i m facing problem, I will have to show
> > all images from phone memory and from sd card in list format with
> > checkbox, thumbnail and paging facility. I m new to android. Can any
> > one give me sample code or link for that?
>
> > Thanks...
> > Pratik
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---