Reputation: 41
I am stuck in a problem. Actually I need unique transaction ID every time uploading record to server. The data for 1 record is large so i can't keep all records in DB table. I tried to keep the transaction Id's in a table and set auto increment but when i uninstall the application it start generating the id's from 1. I tried android global variables which are set in start of application and are only accessible within the app. I need to set a global variable in android which can be accessed even I uninstall my application and then install again. System property also didn't work for me. Any suggestions how i can generate a unique ID every time ?
Upvotes: 0
Views: 3015
Reputation: 3725
How about generating id with help of currentTimeMilliSeconds and mac Address;
WifiManager manager =(WifiManager)getSystemService(Context.WIFI_SERVICE);
WifiInfo info = manager.getConnectionInfo();
String address = info.getMacAddress();
String id=System.currentMilliSeconds()+address;
This will be unique every time for any device.
Upvotes: 0
Reputation: 1422
Generate a unique ID using this
public static String getImageUUID() {
return UUID.randomUUID().toString();
}
Upvotes: 3