Samli to java! - Android Software Development

Anyone wrote anything that does this?
I don't think so but I been trying to reverse some samli files and think wouldn't it be great to have a samli to java converter?
I am trying to write something that does this however, I would not be able to make it auto convert goto jumps to if/while/for statements.
so far I gotten it to look like this for MyDownloadsAdapter.smali:
Code:
public final class MyDownloadsAdapter extends AssetItemAdapter implements LocalAssetCache.AssetStateListener {
private static final Comparator<Asset> myDownloadsComparator;
private volatile boolean mToShowButtonBar;
private final MyDownloadsAdapter.DownloadingAssetViewUpdater mViewUpdater;
static {
) {
myDownloadsComparator=new MyDownloadsAdapter.1();
};
public MyDownloadsAdapter(Context context,Handler handler) {
super(context,handler);
};
private View getAssetView(int position,View convertView,ViewGroup parent) {
};
private View getButtonBarView(int position,View convertView,ViewGroup parent) {
};
private int getHeaderCount(int position) {
};
protected static int getHeaderCount(int position,boolean buttonBar,int numRunning) {
};
private View getHeaderView(int position,View convertView,ViewGroup parent,int title) {
};
private int getItemType(int position) {
};
private int getNumRunningAssets() {
};
private void postNotifyDataSetChanged() {
};
private void setAssetDisplay(MyDownloadsAdapter.ViewHolder holder,Asset asset,int position) {
};
public void addAssets(List p1,List p2) {
};
public void addAssets(List p1,List p2,Runnable callback) {
};
public Asset getAsset(int position) {
};
public int getCount() {
};
public int getItemViewType(int position) {
};
public int getNumUpdates() {
};
public List getUnchangedUpdates() {
};
public View getView(int position,View convertView,ViewGroup parent) {
};
public int getViewTypeCount() {
};
protected void innerAddAllAssets(List p1) {
};
public boolean isEnabled(int position) {
};
public void notifyDataSetChanged() {
};
public void onAssetStateChanged(String serverAssetId,LocalAssetInfo.AssetState newState) {
};
public void setToShowButtonBar(boolean toShowButtonBar) {
};
Main thing is there is a dex2jar however, that seems to not have any of the local variables name kept. So my goal is from samli to java to keep the variable names and hopefully to have simplified output where it isn't like 1 line becoming 10 lines.

Well, I still trying to code it and gotten it to look like this so far:
Code:
public final class MyDownloadsAdapter extends AssetItemAdapter implements LocalAssetCache.AssetStateListener {
private static final Comparator<Asset> myDownloadsComparator;
private volatile boolean mToShowButtonBar;
private final MyDownloadsAdapter.DownloadingAssetViewUpdater mViewUpdater;
static {
) {
myDownloadsComparator=new MyDownloadsAdapter.1();
};
public MyDownloadsAdapter(Context context,Handler handler) {
super(context,handler);
this.mViewUpdater=new MyDownloadsAdapter.DownloadingAssetViewUpdater(context);
this.mToShowButtonBar=0x0;
};
private View getAssetView(int position,View convertView,ViewGroup parent) {
Asset asset = this.getAsset(position);
boolean isRunning = asset.isDownloadingOrInstalling();
int layoutId = null;
MyDownloadsAdapter.ViewHolder holder = null.inflate(layoutId,parent,0x0).getTag();
DownloadProgress progress = this.setAssetDisplay(MyDownloadsAdapter.ViewHolder,asset,position);
LocalAsset localAsset = asset.findMatchingLocalAsset();
};
private View getButtonBarView(int position,View convertView,ViewGroup parent) {
View updateAllButton = MyDownloadsAdapter.ViewHolder.inflate(isRunning,parent,0x0).findViewById(MyDownloadsAdapter.ViewHolder);
};
private int getHeaderCount(int position) {
};
protected static int getHeaderCount(int position,boolean buttonBar,int numRunning) {
int headers = 0x0;
int headers = this.getNumRunningAssets();
};
private View getHeaderView(int position,View convertView,ViewGroup parent,int title) {
};
private int getItemType(int position) {
int numRunning = this.getNumRunningAssets();
};
private int getNumRunningAssets() {
List<Asset> assets = this.getAssets();
int length = this.getNumAssets();
int i = 0x0;
};
private void postNotifyDataSetChanged() {
};
private void setAssetDisplay(MyDownloadsAdapter.ViewHolder holder,Asset asset,int position) {
int adjustedPosition = MyDownloadsAdapter.3;
BitmapDrawable drawable = this.getBitmapAt(adjustedPosition,this.getHeaderCount(position));
};
public void addAssets(List p1,List p2) {
List<Asset> assets = p1;
List<Asset> correctedAssets = p2;
};
public void addAssets(List p1,List p2,Runnable callback) {
List<Asset> assets = p1;
List<Asset> correctedAssets = p2;
};
public Asset getAsset(int position) {
boolean enabled = this.isEnabled(position);
};
public int getCount() {
int extra = enabled;
};
public int getItemViewType(int position) {
};
public int getNumUpdates() {
int num = 0x0;
Iterator i$ = this.getAssets();
Asset asset = this.getAssets();
};
public List getUnchangedUpdates() {
List<Asset> unchangedUpdates = ArrayList;
int length = this.getNumAssets();
int i = 0x0;
Asset asset = this.getAsset(i);
};
public View getView(int position,View convertView,ViewGroup parent) {
int type = this.getItemType(position);
};
public int getViewTypeCount() {
};
protected void innerAddAllAssets(List p1) {
List<Asset> assets = p1;
Iterator i$ = null;
Asset asset = null;
};
public boolean isEnabled(int position) {
int numRunning = this.getNumRunningAssets();
};
public void notifyDataSetChanged() {
List<Asset> assets = this.getAssets();
Iterator i$ = this.getAssets();
Asset asset = this.getAssets();
};
public void onAssetStateChanged(String serverAssetId,LocalAssetInfo.AssetState newState) {
};
public void setToShowButtonBar(boolean toShowButtonBar) {
this.mToShowButtonBar=null;
};

opensource?
definetely interesting!

Code:
System.out.println("I dont get none of this... :P");

Fr4gg0r said:
opensource?
definetely interesting!
Click to expand...
Click to collapse
sure i can release the source. it is quite messy and it decodes using my logic on how i try to read assembly.
i am still no where near done and have to go to taiwan for a funeral service for a week and a half.
prob i will release source of what I did so far at the end of today but seems to be packed with real work today so not sure will I even be able to improve my stuff more.

The smali code keeps parameter names, but not local variable names, so I don't think you can ever get that information back.
As far as rewriting loops and conditions, it would be easier to parse the whole document into a tree of tokens, then look for patterns that usually represent a loop or such. Is baksmali's source open? If the author is building a parse tree, you may have half of the code you need.
Edit: I am really interested in this project. I was thinking about doing something similar this week, as it would be really useful for modifying apps.
Sent from my ADR6300 using XDA App

Adam.h.ogle said:
The smali code keeps parameter names, but not local variable names, so I don't think you can ever get that information back.
Click to expand...
Click to collapse
It all depends on what javac has stored in bytecode. There may be parameter names and may be not, may be local vars names or not.
Adam.h.ogle said:
Is baksmali's source open? If the author is building a parse tree, you may have half of the code you need.
Click to expand...
Click to collapse
Baksmali is open sourced and it needs to analyze code of methods to deodex them, so it has required tools. Search sources for "code analyze" or something like that.
BTW I think this isn't a good approach to decompiling dexes. Decompilation is very hard task, JVM decompilers exist several years and they aren't perfect. I prefer dex2jar approach.

well, i think samli does have local variables stored and it is like
.local
samli have more information than normal java byte code. Sometimes it doesnt store variables but lot of time it does based on what I looked into.
well here is where my source is:
http://www.multiupload.com/SLZXWUUOS7
i did no updates today because I am busy at work and still busy. :/
btw. I am doing this in the method of how I read assembly code.
May not be a good or, or it might be a good way but who knows.
Well i guess my goal isnt liek decompiling but more like changing assembly in salmi to more of a readable format.

TheBuzzer said:
samli have more information than normal java byte code.
Click to expand...
Click to collapse
No, it hasn't. Dalvik bytecode isn't compiled from Java directly, but it's converted from JVM bytecode, so it can't contain more data.
Code:
Java sources ----> JVM bytecode (*.class) -----> Dalvik bytecode (*.dex)
javac dx
TheBuzzer said:
Sometimes it doesnt store variables but lot of time it does based on what I looked into.
Click to expand...
Click to collapse
It all depends on compilation flags. There is a -g switch to javac to enable or disable generation of various debugging symbols (.local, .parameter, .line, .source). I think .parameter and .line are enabled by default in new Android project, but you could change it, if you want. Also ProGuard removes all debugging symbols, if app's author uses it.
TheBuzzer said:
btw. I am doing this in the method of how I read assembly code.
May not be a good or, or it might be a good way but who knows.
Well i guess my goal isnt liek decompiling but more like changing assembly in salmi to more of a readable format.
Click to expand...
Click to collapse
Yeah, I understand, but I know this is much harder than it seems. Some time ago I was trying to create a tool to "decompile" declarations of classes, members and methods only. I wanted to keep smali code untouched, but extract and generate declarations in Java format. I was thinking this will be really easy, declarations are very straightforward, trivial to convert to another format.
I was wrong. There were more exceptions than rules in real, not sample app. Unfortunately compilation isn't a 1:1 conversion, so it's sometimes very hard to revert. And you want to "decompile" body of methods as well - this will be much, much harder.
Whole story, if you're curious: http://code.google.com/p/android-apktool/issues/detail?id=88
If you want to generate Java code just to look at it, but make any changes in smali code, then it'll be ok. But if you want to decompile dexes to form, that you will be able to compile back, than I think you'll fail, sorry.

ya it wont be completely workable java code.
like i said I am not going to bother about coding it to convert goto to the right type of loops
it is just to make it eaiser to read because I am trying to reverse the whole new vending apk for fun. I am writing this to help me in the progress because reading the salmi is a pain if there is tons of files and long classes.

salmi or salami?

Related

[Q] AlertDialog (-> list with a lot of elements) how to handle orientation-change

Hi,
A few weeks ago I started developing an Android app but I've gut one problem
If the user changed the orientation of his phone the Activity is of course newly created. If there is ProgressDialog opened, I simply open a new one and the user does not realize it, but if I show an AlertDialog containing a few hundred elements and the user scrolls a bit he/she will realize it after I recreate the AlertDialog because the dialog will start again with the first element and the user has to scroll newly to the element he wants.
How I handle the "ListDialog":
At first I have two classes which simplify the ListDialog because I use it a few times...
ListDialog class:
Code:
public class ListDialog {
public static int CHOOSE_MODE_ONLINE = 0x01;
public static int CHOOSE_MODE_BOOKMARK = 0x02;
public static int CHOOSE_MODE_LOCAL = 0x03;
public static int CHOOSE_CHAPTER_ONLINE_DOWNLOAD = 0x04;
public static int CHOOSE_CHAPTER_BOOKMARK_DOWNLOAD = 0x05;
public static int CHOOSE_CHAPTER_ONLINE_READ = 0x06;
public static int CHOOSE_CHAPTER_BOOKMARK_READ = 0x07;
public static int CHOOSE_CHAPTER_LOCAL_READ = 0x08;
public static int CHOOSE_CHAPTER_LOCAL_DELETE = 0x09;
public static int GOTO_PAGE = 0x0A;
public static void show(Context context, String title, CharSequence[] elems, final ListMethodInvoker invoker)
{
AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setTitle(title);
builder.setItems(elems, new DialogInterface.OnClickListener() {
%mail%Override
public void onClick(DialogInterface dialog, int which) {
invoker.invoke(which);
}
});
builder.setOnCancelListener(new OnCancelListener() {
%mail%Override
public void onCancel(DialogInterface dialog) {
invoker.cancel();
}
});
AlertDialog dialog = builder.create();
dialog.show();
}
}
ListMethodInvoker class:
Code:
public class ListMethodInvoker {
public void invoke(int id)
{
}
public void cancel()
{
}
}
and now I create the dialog:
Code:
ApplicationController.get().addOpenedDialog(ListDialog.CHOOSE_MODE_ONLINE);
ListDialog.show(OnlineActivity.this,
mangaController.getManga().getMangaName(),
new CharSequence[]{"Add to Bookmarks", "Download a Chapter", "Read a Chapter"},
new ListMethodInvoker()
{
%mail%Override
public void invoke(int id)
{
ApplicationController.get().removeOpenedDialog(ListDialog.CHOOSE_MODE_ONLINE);
switch(id)
{
case 0: addBookmark(mangaController.getManga()); break;
case 1:
ApplicationController.get().addOpenedDialog(ListDialog.CHOOSE_CHAPTER_ONLINE_DOWNLOAD);
handleChapter(ChapterMode.Download);
break;
case 2:
ApplicationController.get().addOpenedDialog(ListDialog.CHOOSE_CHAPTER_ONLINE_READ);
handleChapter(ChapterMode.Read);
break;
}
}
%mail%Override
public void cancel()
{
ApplicationController.get().removeOpenedDialog(ListDialog.CHOOSE_MODE_ONLINE);
}
});
I also add the ID of the dialog to my ApplicationController which allows me to remember if a dialog has been openend and I can recreate it when onCreate(...) is called again.
(The ApplicationController uses the singleton design pattern which always allows me to retrieve the same instance of the ApplicationController.)
Thanks in advance
best regards
mike
btw: If you wonder why I write %mail% instead of the correct symbol, I get the following exception message if I use it: To prevent spam to the forums, new users are not permitted to post outside links in their messages. All new user accounts will be verified by moderators before this restriction is removed.

[Q] My App use API of Google Maps but the map is slow

Hello Boys,
I am a new Android developer and I'm developing an app with the API of Google Maps.
Into an area of the map I place many markers.
The application works correctly, but the map scroolling and the map zoom isn't quick, everything goes slow.
The marker that I have included in the map is in the "png" format image, and his weighs is approximately 600 bytes.
it is possible that many marker object cause low map scrool?
this is the code of my APP:
Code:
plublic class IDC extends MapActivity {
private LocationManager locationManager;
private LocationListener locationListener;
private MapController mc;
private MapView mapView;
private String myPosition;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
String errore="";
myPosition="";
try{
mapView = (MapView) findViewById(R.id.mapview);
mc = mapView.getController();
locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
locationListener = new GPSLocationListener();
//getMyLocation();
MyDBHelper myDB = new MyDBHelper(IDS.this);
Cursor cursor= myDB.query(new String[] { "x", "y", "y2", "w", "k", "latitude", "longitude"});
//Log.i("NOMI", "TOT. NOMI"+cursor.getCount());
List<Overlay> mapOverlays = mapView.getOverlays();
Drawable drawable = this.getResources().getDrawable(R.drawable.mm_20_blue);
MyItemizedOverlay itemizedoverlay = new MyItemizedOverlay(drawable,IDS.this);
List<Address> address = new ArrayList<Address>();
Log.i("TOT TUPLE", " = "+cursor.getCount());
while(cursor.moveToNext()){
String s= cursor.getString(0);
errore=s;
String nome[]=s.split("-");
// Log.i("Pos Colonna NOME", ""+cursor.getColumnIndex("nome"));
// Log.i("Pos. in Colonna", ""+cursor.getString(0));
//address.addAll(gc.getFromLocationName(nome[1], 1));
//Address a= address.get(address.size()-1);
String la=cursor.getString(5);
String lo=cursor.getString(6);
double latitude= Double.parseDouble(la);
double longitude= Double.parseDouble(lo);
int lan= (int)(latitude*1E6);
int lon= (int)(longitude*1E6);
GeoPoint point = new GeoPoint(lan, lon);
String tel1=cursor.getString(1);
String tel2=cursor.getString(2);
String mail=cursor.getString(4);
String web=cursor.getString(3);
String info[]= {tel1,tel2,nome[1],web,mail};
MyOverlayItem overlayitem = new MyOverlayItem(point, "Hello", nome[0], info);
//mc.animateTo(point);
itemizedoverlay.addOverlay(overlayitem);
mapOverlays.add(itemizedoverlay);
}
mapView.setBuiltInZoomControls(true);
mc.setZoom(6);
}catch (Exception e) {
e.printStackTrace();
}
}
}
Code:
public class MyItemizedOverlay extends ItemizedOverlay {
private ArrayList<OverlayItem> mOverlays = new ArrayList<OverlayItem>();
private Context mContext;
private CustomizeDialog customizeDialog;
public MyItemizedOverlay(Drawable defaultMarker) {
super(boundCenterBottom(defaultMarker));
}
public MyItemizedOverlay(Drawable defaultMarker, Context context) {
super(boundCenterBottom(defaultMarker));
mContext = context;
}
protected boolean onTap(int index)
MyOverlayItem item = (MyOverlayItem) mOverlays.get(index);
customizeDialog = new CustomizeDialog(mContext);
customizeDialog.setPersonalText(item.getSnippet());
String []info= item.getInfo();
customizeDialog.setT1(info[0]);
customizeDialog.setT2(info[1]);
customizeDialog.setA(info[2]);
customizeDialog.setW(info[3]);
customizeDialog.setM(info[4]);
customizeDialog.show();
return true;
}
protected OverlayItem createItem(int i) {
return mOverlays.get(i);
}
public int size() {
return mOverlays.size();
}
public void addOverlay(OverlayItem overlay) {
mOverlays.add(overlay);
populate();
}
}
what is the problem??....PLEASE, HELP ME!!

[LIST] Code/Feature an app should always have

Hi!
I develop Android since 1 year and if I read my first code, i put my hands over my hair
Days by days and lines by lines, the developer skill increased and after 1 year i collected some feature and block of code that I always use (some are like tips/triks).
I wanna share them with all of you and take suggestion or other block of codes you always use.
1) CONSTANTS CLASS
In this "final" class i put all constants and methods I need in my activities.
Code:
public final class Constants {
public static final boolean DEBUG = true;
public static final boolean LOG = true;
public static final String TAG = "APP_NAME";
public static final String TAG_PREFERENCE = "PREFERENCE";
public static final String TAG_WIDGET = "WIDGET";
public static final String marketlINK = "market://details?id=app.name.etc";
public static final String oldversion="0.9";
public static final String version="1";
public static final String getCurrentDate(){
Calendar c = Calendar.getInstance();
SimpleDateFormat df = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
String formattedDate = df.format(c.getTime());
return formattedDate;
}
}
2)LOG WRAPPER CLASS
This wrapper class allow to disable all log output in logcat.
It's possible to obtain the same results by using proguard.
Code:
public class Log {
static final boolean LOG = Constants.LOG;
public static void i(String tag, String string) {
if (LOG) android.util.Log.i(tag, string);
}
public static void e(String tag, String string) {
if (LOG) android.util.Log.e(tag, string);
}
public static void d(String tag, String string) {
if (LOG) android.util.Log.d(tag, string);
}
public static void v(String tag, String string) {
if (LOG) android.util.Log.v(tag, string);
}
public static void w(String tag, String string) {
if (LOG) android.util.Log.w(tag, string);
}
}
3)FIRST TIME LAUNCH
Check from sharedpreferences if it's the first time the app is launched.
Code:
final boolean firstTime = prefs.getBoolean(Constant.version, true);
if (firstTime){
editor.remove(Constant.oldversion);
editor.putBoolean(Constant.version, false);
editor.commit();
}
4)CHECK NUMBER OF START
Check how many times the app is launched and do something..
Code:
int counter = prefs.getInt("numRun", 0);
counter++;
prefs.edit().putInt("numRun",counter).commit();
if (counter==5){
openDialog();
prefs.edit().putInt("numRun",0).commit();
}
If you have suggestions or other block of code-lines, i'll include them on the first post!
reserved
Are you sure that youre developing android?
Sent from my ST18i using Tapatalk 2

[Q] No idea how to load onChildClick in my ExpandableListView.

I have an expandable list view with 2 parents and 3 children. I want to open a dialog based on each click. I can't find any examples showing you how to call something based on positions. At least not with the ExpandableListView tutorial I followed.
Code:
public class MainActivity extends Activity implements OnClickListener {
private LinkedHashMap<String, HeaderInfo> myDepartments = new LinkedHashMap<String, HeaderInfo>();
private ArrayList<HeaderInfo> deptList = new ArrayList<HeaderInfo>();
private MyListAdapter listAdapter;
private ExpandableListView myList;
[user=439709]@override[/user]
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// Just add some data to start with
loadData();
// get reference to the ExpandableListView
myList = (ExpandableListView) findViewById(R.id.myList);
// create the adapter by passing your ArrayList data
listAdapter = new MyListAdapter(MainActivity.this, deptList);
// attach the adapter to the list
myList.setAdapter(listAdapter);
// listener for child row click
myList.setOnChildClickListener(myListItemClicked);
// listener for group heading click
myList.setOnGroupClickListener(myListGroupClicked);
}
// load some initial data into out list
private void loadData() {
addProduct("Parent One", "Child One");
addProduct("Parent One", "Child Two");
addProduct("Parent One", "Child Three");
addProduct("Parent Two", "Child One");
addProduct("Parent Two", "Child Two");
addProduct("Parent Two", "Child Three");
}
// our child listener
private OnChildClickListener myListItemClicked = new OnChildClickListener() {
[user=439709]@override[/user]
public boolean onChildClick(ExpandableListView parent, View v,
int groupPosition, int childPosition, long id) {
// Create a switch that switches on the specific child position.
// get the group header
HeaderInfo headerInfo = deptList.get(groupPosition);
// get the child info
DetailInfo detailInfo = headerInfo.getProductList().get(
childPosition);
// display it or do something with it
// custom dialog
final Dialog dialog = new Dialog(MainActivity.this);
dialog.setContentView(R.layout.cdialog);
// dialog.setTitle(R.id.titlebar);
dialog.setTitle(R.string.titlebar);
dialog.show();
return false;
}
};
// our group listener
private OnGroupClickListener myListGroupClicked = new OnGroupClickListener() {
public boolean onGroupClick(ExpandableListView parent, View v,
int groupPosition, long id) {
// get the group header HeaderInfo headerInfo =
deptList.get(groupPosition);
// display it or do something with it
return false;
}
};
I can get a custom dialog open if I click a child, but it's not set to any specific parent and child.
Any ideas?
EDIT ADD: Got it. Tried a switch/case like this and it worked. Finally! After two days of trying to understand it.:fingers-crossed:
Code:
switch(groupPosition) {
case 1:
switch (childPosition) {
case 0:
Intent protheanIntent = new Intent(Codex.this, CodexProthean.class);
Codex.this.startActivity(protheanIntent);
break;
case 1:
Intent rachniIntent = new Intent(Codex.this, CodexRachni.class);
Codex.this.startActivity(rachniIntent);
break;
}
case 2:
switch (childPosition) {
case 2:
Intent asariIntent = new Intent(Codex.this, CodexAsari.class);
Codex.this.startActivity(asariIntent);
break;
}
}

adding an image column to an existing tabe in sqlite database

I wanted to add a column which will be able to store images, to an existing sqlite table which has two columns, What datatype column do i create so that i can be able to store images in my database?
My code looks like this
public class Sqlite extends SQLiteOpenHelper {
public static final String DB_NAME = "vault";
public static final int DB_VERSION = 1;
public static final String DB_CREATE = "CREATE TABLE data(key VARCHAR(32) PRIMARY KEY NOT NULL, value VARCHAR(100) NOT NULL)";
public SQLiteDatabase db;
public Context context;
public Sqlite(Context context) {
super(context, DB_NAME, null, DB_VERSION);
this.context = context;
}
@override
public void onCreate(SQLiteDatabase db) {
this.db = db;
this.db.execSQL(DB_CREATE);
}
@override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
}
@override
public synchronized void close() {
if(this.db != null) {
this.db.close();
super.close();
}
}
public List<VaultItem> getAll() throws Exception {
// load items
List<VaultItem> items = new ArrayList<VaultItem>();
// query db
Cursor c = db.query("data", new String[]{"key", "value"}, null, null, null, null, null);
c.moveToFirst();
while(!c.isAfterLast()) {
items.add(new VaultItem(c.getString(0), SimpleCrypto.decrypt(c.getString(1))));
c.moveToNext();
}
return items;
}
public VaultItem getOne(String key) throws Exception {
Cursor c = db.query("data", new String[]{"key", "value"}, "key = '"+key+"'", null, null, null, null);
c.moveToFirst();
VaultItem item=null;
while(!c.isAfterLast()) {
item = new VaultItem(c.getString(0), SimpleCrypto.decrypt(c.getString(1)));
c.moveToNext();
}
return item;
}
}
This table only stores, .txt documents, with their name and content. I want it to to be able to store .doc documents and .jpg files. Please help me...
A Blob data type is what you would want to store in a database for images. http://developer.android.com/reference/java/sql/Blob.html has good info on it.
Basically take your image (bitmap) and convert to byte[] to store in db. Retrieve it by converting byte array to bitmap.
Do not forget to update your DB version to update db with new fields.
Noted to self thrice via tapatalk

Categories

Resources