im currently working on an app that downloads files using the firebase storage and firebase database to store the url linking to the storage. the fire base database tree looks a bit like this
Apps | app1 | name my app download 1 url http://link to download about About the app your downloading image image url for the app your downloading downloads = 0 | app2 (Same data as above)
i have custom base adapter which allows me to add the image url and about value. when somebody click an item in my list it downloads and installs the app you selected, by grabbing the position of the item and then grabbing the url from the database using httpget.
what id like is when they click the item it auto increments the child downloads by 1 so it acts as a download counter.
mrootRef = new Firebase("https://admob-app-id-3020090926.firebaseio.com/Apps");
mlv = (ListView) findViewById(R.id.lvFilmapps);
mrootRef.child("Filmapps").addChildEventListener(new ChildEventListener() {
@Override
public void onChildAdded(DataSnapshot dataSnapshot, String s) {
final String appname = dataSnapshot.child("name").getValue(String.class);
final String url = dataSnapshot.child("url").getValue(String.class);
final String apkname = dataSnapshot.child("apk").getValue(String.class);
final String about = dataSnapshot.child("about").getValue(String.class);
final String appimg = dataSnapshot.child("image").getValue(String.class);
FilmArray.add(appname);
urlList.add(url);
ApkList.add(apkname);
Aboutapp.add(about);
appImage.add(appimg);
//String[] convertion for the BaseAdpater
String[] arr = FilmArray.toArray(new String[FilmArray.size()]);
String[] arr1 = Aboutapp.toArray(new String[Aboutapp.size()]);
String[] arr2 = appImage.toArray(new String[appImage.size()]);
mlv.setAdapter(new dataListAdapter(arr,arr1,arr2));
new dataListAdapter(arr,arr1,arr2).notifyDataSetChanged();
mlv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
newnamestring = ApkList.get(i).toString();
apkNames = FilmArray.get(i).toString();
new DownloadFileFromURL().execute(urlList.get(i));
}
});
}