MediaStore Uri for External? - java

As a MediaStore newbie's, I dunno what's wrong with this uri:
MediaStore.Files.getContentUri("external")
Those uri's keeps returns to zero.
My example codes:
String file = null;
String sortBy = "";
if (filterSort == "time") {
sortBy = MediaStore.Files.FileColumns.DATE_MODIFIED;
} else if (filterSort == "size") {
sortBy = MediaStore.Files.FileColumns.SIZE;
}
String[] projection = {MediaStore.Files.FileColumns.DATA};
android.database.Cursor cursor = getContentResolver().query(MediaStore.Files.getContentUri("external"), projection, null, null, sortBy + "DESC");
if (cursor != null) {
while (cursor.moveToNext()) {
file = cursor.getString(0);
states.add(file);
}
cursor.close();
}
Trying to solve with
Uri.parse worked but did not apply sorting filter's. Back with
MediaStore.Files.getContentUri("external") , it keeps giving me this via Exception on Android 8.1 devices:
android.database.sqlite.SQLiteException:
no such column: date_modifiedDESC (code 1): , while compiling: SELECT _data FROM files WHERE ( invalid=0) ORDER BY date_modifiedDESC
Is there any way to solve/change/do?

Nor sure what blackapps is referring to as he does not address the question in any way.
There are a number of uris, depending what you want to extract.
for example:
public Uri get_audio_media_uri(){
Uri uri_to_use = null;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
uri_to_use = MediaStore.Audio.Media.getContentUri(MediaStore.VOLUME_EXTERNAL);
} else {
uri_to_use = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI;
}
return uri_to_use;
}
or for artists;
public Uri get_audio_artist_uri(){
Uri uri_to_use = null;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
uri_to_use = MediaStore.Audio.Artists.getContentUri(MediaStore.VOLUME_EXTERNAL);
} else {
uri_to_use = MediaStore.Audio.Artists.EXTERNAL_CONTENT_URI;
}
return uri_to_use;
}
the part "date_modifiedDESC" is what causes the issue as it requires a space "date_modified DESC"
I suggest you amend your projection, for example
String projection[];
if (Build.VERSION.SDK_INT == Build.VERSION_CODES.Q) {
//no _DATA column in Q
projection = new String[]{
MediaStore.Audio.Media._ID,
MediaStore.Audio.Media.ALBUM,
MediaStore.Audio.Media.TITLE,
MediaStore.Audio.Media.ARTIST,
MediaStore.Audio.Media.DURATION,
MediaStore.Audio.Media.DATE_MODIFIED
};
} else {
projection = new String[]{
MediaStore.Audio.Media._ID,
MediaStore.Audio.Media.ALBUM,
MediaStore.Audio.Media.TITLE,
MediaStore.Audio.Media.ARTIST,
MediaStore.Audio.Media.DURATION,
MediaStore.Audio.Media.DATA
MediaStore.Audio.Media.DATE_MODIFIED
};
}
instead of MediaStore.Files.FileColumns.DATE_MODIFIED;

Related

MediaStore query don't get all artists and camera videos

I use the code bellow to query all artists of music files, the method works good but the problem it's missing artist column called and that column is visible in other music apps, so am I missing something in the query process ?
void loadAudioData() {
ContentResolver contentResolver = Objects.requireNonNull(getActivity()).getContentResolver();
final Uri uri = MediaStore.Audio.Artists.EXTERNAL_CONTENT_URI;
String[] projection = {MediaStore.Audio.Artists._ID, MediaStore.Audio.Media.ARTIST, MediaStore.Audio.Artists.ARTIST,
MediaStore.Audio.Artists.NUMBER_OF_TRACKS};
cursor = contentResolver.query(uri, projection, null, null, null);
if (cursor != null && cursor.moveToFirst())
while (cursor.moveToNext())
songsList.add(new Song(cursor.getString(2), cursor.getString(0), cursor.getString(3)));
cursor.close();
String sortType = sharedPreferences.getString("artist_sort", "artist a to z");
boolean isReverse = sharedPreferences.getBoolean("artist_sort_isReverse", false);
if (sortType != null)
Song.sortArtist(songsList, sortType, isReverse);
}
the same problem here too but with camera videos, the query process gets all videos except camera videos.
public List<ImageVideo> getAllVideos(){
Uri uri = MediaStore.Video.Media.EXTERNAL_CONTENT_URI;
String[] projection = {MediaStore.Video.Media.DATA, MediaStore.Video.Media.TITLE};
final String orderBy = MediaStore.Video.Media.DATE_TAKEN;
Cursor cursor = Objects.requireNonNull(getContext()).getContentResolver().query(uri, projection,
null, null, orderBy + " DESC");
videoList = new ArrayList<>();
if(cursor.moveToFirst()) {
while (cursor.moveToNext()) {
videoList.add(new ImageVideo(cursor.getString(1), cursor.getString(0)));
}
}
cursor.close();
return videoList;
}

(loading images from gallery to app) emulator API 29 shows all pictures but when i run the mobile phone as an emulator no pictures are shown

public class ImagesGallery {
#SuppressLint("Recycle")
#RequiresApi(api = Build.VERSION_CODES.Q)
public static ArrayList<String> listOfImages (Context context){
Uri uri;
Cursor cursor;
int column_index_data;
ArrayList<String> listOfAllImages = new ArrayList<>();
String absolutePathOfImages;
uri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI;
String[] projection = new String[]{MediaStore.MediaColumns.DATA};
String orderBy = MediaStore.Video.Media.DATE_TAKEN;
cursor = context.getContentResolver().query(uri, projection, null, null, orderBy+" DESC");
if (cursor != null){
column_index_data = cursor.getColumnIndexOrThrow(MediaStore.MediaColumns.DATA);
while (cursor.moveToNext()){
absolutePathOfImages = cursor.getString(column_index_data);
listOfAllImages.add(absolutePathOfImages);
}
}
return listOfAllImages;
}
}
Activity mList (String-ArrayList) in Activity
private void loadImages() {
recyclerView.setHasFixedSize(true);
recyclerView.setLayoutManager(new GridLayoutManager(this, 4));
mList = ImagesGallery.listOfImages(this);
galleryAdapter = new GalleryAdapter(PhotoActivity.this, mList, new GalleryAdapter.PhotoListener() {
#Override
public void onPhotoClick(String path) {
Glide.with(PhotoActivity.this).load(path).into(image);
imageData = Uri.fromFile(new File(path));
}
});
recyclerView.setAdapter(galleryAdapter);
gallery_number.setText("Photos ("+mList.size()+")");
}
How can i make (MediaStore.MediaColumns.DATA) situation compatible with android 10 I read the documentation but could not solve the problem,Any explanation about this situation would help me

Missing file path

I would like to send the image and text that I received from the user to the server but I have problems.
void sendData(final String username) {
String url = "http://hesabdarbartar.ir/api/update";
final SharedPreferences preferences = getApplicationContext().getSharedPreferences("data_user", Context.MODE_PRIVATE);
AndroidNetworking.upload(url)
.addMultipartFile(Key.IMAGE, new File(path))
.addMultipartParameter(Key.NAME, username)
.addHeaders(Key.TOKEN, preferences.getString("api_token", ""))
.build()
.getAsObject(User.class, new ParsedRequestListener<User>() {
#Override
public void onResponse(User response) {
try {
preferences.edit().putString("name", response.getName()).apply();
preferences.edit().putString("pic", response.getPic()).apply();
startActivity(new Intent(getApplicationContext(), MainActivity.class));
finish();
} catch (Exception e) {
Toast.makeText(getApplicationContext(), "خطا در ارتباط با سرور!", Toast.LENGTH_SHORT).show();
}
}
#Override
public void onError(ANError anError) {
Log.i("ererer", "" + String.valueOf(anError));
}
});
}
void askReadPermission() {
Dexter.withActivity(this)
.withPermission(Manifest.permission.READ_EXTERNAL_STORAGE)
.withListener(new PermissionListener() {
#Override
public void onPermissionGranted(PermissionGrantedResponse response) {
pickImage();
}
#Override
public void onPermissionDenied(PermissionDeniedResponse response) {
if (response != null && response.isPermanentlyDenied()) {
Snackbar.make(btn_confirm, "برای انتخاب فایل دسترسی ضروری است!", Snackbar.LENGTH_LONG).setAction("اجازه دادن!", new View.OnClickListener() {
#Override
public void onClick(View v) {
Intent i = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
i.setData(Uri.fromParts("package", getApplicationContext().getPackageName(), null));
startActivity(i);
}
}).show();
} else {
Snackbar.make(btn_confirm, "برای انتخاب فایل دسترسی ضروری است!", Snackbar.LENGTH_LONG).show();
}
}
#Override
public void onPermissionRationaleShouldBeShown(PermissionRequest permission, PermissionToken token) {
}
}).check();
}
private void pickImage() {
Intent photoPickerIntent = new Intent(Intent.ACTION_PICK);
photoPickerIntent.setType("image/*");
startActivityForResult(photoPickerIntent, 1);
}
#Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == 1 && resultCode == Activity.RESULT_OK && data.getData() != null) {
path = data.getData().getPath();
btn_confirm.setEnabled(true);
img_prof.setImageURI(data.getData());
}
}
}
Here's a snapshot of the program's problems
What you receive in onActivityResult() is an Uri of the image, not its real path. You should convert it to the real path, then you can use it in new File(path). There is a converter:
public class RealPathUtil {
public static String getRealPath(Context context, Uri fileUri) {
String realPath;
// SDK < API11
if (Build.VERSION.SDK_INT < 11) {
realPath = RealPathUtil.getRealPathFromURI_BelowAPI11(context, fileUri);
}
// SDK >= 11 && SDK < 19
else if (Build.VERSION.SDK_INT < 19) {
realPath = RealPathUtil.getRealPathFromURI_API11to18(context, fileUri);
}
// SDK > 19 (Android 4.4) and up
else {
realPath = RealPathUtil.getRealPathFromURI_API19(context, fileUri);
}
return realPath;
}
#SuppressLint("NewApi")
public static String getRealPathFromURI_API11to18(Context context, Uri contentUri) {
String[] proj = {MediaStore.Images.Media.DATA};
String result = null;
CursorLoader cursorLoader = new CursorLoader(context, contentUri, proj, null, null, null);
Cursor cursor = cursorLoader.loadInBackground();
if (cursor != null) {
int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
cursor.moveToFirst();
result = cursor.getString(column_index);
cursor.close();
}
return result;
}
public static String getRealPathFromURI_BelowAPI11(Context context, Uri contentUri) {
String[] proj = {MediaStore.Images.Media.DATA};
Cursor cursor = context.getContentResolver().query(contentUri, proj, null, null, null);
int column_index = 0;
String result = "";
if (cursor != null) {
column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
cursor.moveToFirst();
result = cursor.getString(column_index);
cursor.close();
return result;
}
return result;
}
/**
* Get a file path from a Uri. This will get the the path for Storage Access
* Framework Documents, as well as the _data field for the MediaStore and
* other file-based ContentProviders.
*
* #param context The context.
* #param uri The Uri to query.
* #author paulburke
*/
#SuppressLint("NewApi")
public static String getRealPathFromURI_API19(final Context context, final Uri uri) {
final boolean isKitKat = Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT;
// DocumentProvider
if (isKitKat && DocumentsContract.isDocumentUri(context, uri)) {
// ExternalStorageProvider
if (isExternalStorageDocument(uri)) {
final String docId = DocumentsContract.getDocumentId(uri);
final String[] split = docId.split(":");
final String type = split[0];
if ("primary".equalsIgnoreCase(type)) {
return Environment.getExternalStorageDirectory() + "/" + split[1];
}
// TODO handle non-primary volumes
}
// DownloadsProvider
else if (isDownloadsDocument(uri)) {
final String id = DocumentsContract.getDocumentId(uri);
final Uri contentUri = ContentUris.withAppendedId(
Uri.parse("content://downloads/public_downloads"), Long.valueOf(id));
return getDataColumn(context, contentUri, null, null);
}
// MediaProvider
else if (isMediaDocument(uri)) {
final String docId = DocumentsContract.getDocumentId(uri);
final String[] split = docId.split(":");
final String type = split[0];
Uri contentUri = null;
if ("image".equals(type)) {
contentUri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI;
} else if ("video".equals(type)) {
contentUri = MediaStore.Video.Media.EXTERNAL_CONTENT_URI;
} else if ("audio".equals(type)) {
contentUri = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI;
}
final String selection = "_id=?";
final String[] selectionArgs = new String[]{
split[1]
};
return getDataColumn(context, contentUri, selection, selectionArgs);
}
}
// MediaStore (and general)
else if ("content".equalsIgnoreCase(uri.getScheme())) {
// Return the remote address
if (isGooglePhotosUri(uri))
return uri.getLastPathSegment();
return getDataColumn(context, uri, null, null);
}
// File
else if ("file".equalsIgnoreCase(uri.getScheme())) {
return uri.getPath();
}
return null;
}
/**
* Get the value of the data column for this Uri. This is useful for
* MediaStore Uris, and other file-based ContentProviders.
*
* #param context The context.
* #param uri The Uri to query.
* #param selection (Optional) Filter used in the query.
* #param selectionArgs (Optional) Selection arguments used in the query.
* #return The value of the _data column, which is typically a file path.
*/
public static String getDataColumn(Context context, Uri uri, String selection,
String[] selectionArgs) {
Cursor cursor = null;
final String column = "_data";
final String[] projection = {
column
};
try {
cursor = context.getContentResolver().query(uri, projection, selection, selectionArgs,
null);
if (cursor != null && cursor.moveToFirst()) {
final int index = cursor.getColumnIndexOrThrow(column);
return cursor.getString(index);
}
} finally {
if (cursor != null)
cursor.close();
}
return null;
}
/**
* #param uri The Uri to check.
* #return Whether the Uri authority is ExternalStorageProvider.
*/
public static boolean isExternalStorageDocument(Uri uri) {
return "com.android.externalstorage.documents".equals(uri.getAuthority());
}
/**
* #param uri The Uri to check.
* #return Whether the Uri authority is DownloadsProvider.
*/
public static boolean isDownloadsDocument(Uri uri) {
return "com.android.providers.downloads.documents".equals(uri.getAuthority());
}
/**
* #param uri The Uri to check.
* #return Whether the Uri authority is MediaProvider.
*/
public static boolean isMediaDocument(Uri uri) {
return "com.android.providers.media.documents".equals(uri.getAuthority());
}
/**
* #param uri The Uri to check.
* #return Whether the Uri authority is Google Photos.
*/
public static boolean isGooglePhotosUri(Uri uri) {
return "com.google.android.apps.photos.content".equals(uri.getAuthority());
}
}

Android (Java) - lookup contact by email and preview if exists

Right now we have an app where we (after permissions) lookup a contact, and if they exist, display their contact card. However the lookup seems very inefficient, it loops through everyone, doesn't seem right. Is there a better query contacts db to lookup ONLY contacts that have an email address that we need?
Current Code Below (not efficient):
public static void showCardIfPossible(String email, Context context) {
Long contactId = lookupByEmail(email, context);
if (contactId != null) {
viewCardFor(context, contactId);
}
}
public static Long lookupByEmail(String email, Context context) {
Long contactId = null;
ContentResolver cr = context.getContentResolver();
Cursor cursor = cr.query(ContactsContract.Contacts.CONTENT_URI,
null, null, null, null);
if (cursor == null || cursor.getCount() == 0) {
return null;
}
while (cursor.moveToNext())
{
String id = cursor.getString(cursor.getColumnIndex(ContactsContract.Contacts._ID));
Cursor cur1 = cr.query(
ContactsContract.CommonDataKinds.Email.CONTENT_URI, null,
ContactsContract.CommonDataKinds.Email.CONTACT_ID + " = ?",
new String[]{id}, null);
if (cur1 != null && cur1.getCount() > 0) {
while (cur1.moveToNext()) {
//to get the contact names
String contactName=cur1.getString(cur1.getColumnIndex(ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME));
String contactEmail = cur1.getString(cur1.getColumnIndex(ContactsContract.CommonDataKinds.Email.DATA));
if(email.equals(contactEmail) || email.equals(contactName)){
contactId = Long.valueOf(id);
}
}
cur1.close();
}
}
cursor.close();
return contactId;
}
public static void viewCardFor(Context context, long contactId) {
Intent intent = new Intent(Intent.ACTION_VIEW);
Uri uri = Uri.withAppendedPath(ContactsContract.Contacts.CONTENT_URI, String.valueOf(contactId));
intent.setData(uri);
context.startActivity(intent);
}
Yes, you can just query directly on the Email.CONTENT_URI and using selection to find the right contact:
public static Long lookupByEmail(String email, Context context) {
ContentResolver cr = context.getContentResolver();
Long contactId = null;
String[] projection = new String[] { Email.CONTACT_ID };
String selection = Email.ADDRESS + "='" + email + "'";
Cursor cur = cr.query(Email.CONTENT_URI, projection, selection, null, null);
if (cur != null) {
if (cur.moveToFirst()) {
contactId = cur.getLong(0);
}
cur.close();
}
return contactId;
}

How to create a conversation from the messages in inbox,sent,draft database of android

See the picture below and i want to create a conversation like this i can do the designing part but i need to create a database for the messages to be in conversation format
See the picture below and i want to create a conversation like this i can do the designing part but i need to create a database for the messages to be in conversation format
messaging.java
< private static String LIST_SEPARATOR = "!##$%^&*1234__/-|:..:|-/__*4321&^%$##!";
public List<String> phno= new ArrayList<>();
public List<String> nam=new ArrayList<>();
public List<String> message=new ArrayList<>();
public List<String> time=new ArrayList<>();
public List<String> type=new ArrayList<>();
public List<String> lstMsg=new ArrayList<>();
public List<String> lstTime=new ArrayList<>();
public List<String> lstType=new ArrayList<>();
public List<String> tempMsg=new ArrayList<>();
public List<String> tempTime=new ArrayList<>();
public List<String> tempKind=new ArrayList<>();
#Nullable
#Override
public IBinder onBind(Intent intent) {
return null;
}
#Override
public int onStartCommand(Intent intent, int flags, int startId) {
String address;
String[] reqCols = new String[]{"_id", "thread_id", "address", "person", "date", "body", "type"};
Uri URI;
ContentResolver cr = getContentResolver();
String[] columns = new String[]{"address", "person", "date", "body", "type"};
Cursor cursor1;
int i,c=0;
//gets phone numbers
//inbox
URI = Uri.parse("content://sms/inbox");
cursor1 = cr.query(URI, reqCols, null, null, null);
if (cursor1.getCount() > 0) {
while (cursor1.moveToNext()) {
address = cursor1.getString(cursor1.getColumnIndex(columns[0]));
for (i = 0; i < phno.size(); i++){
if(address.equals(phno.get(i))) {
c++;
break;
}
}
if(c==0)
phno.add(address);
else
c=0;
}
}
cursor1.close();
//sentbox
URI = Uri.parse("content://sms/sent");
cursor1 = cr.query(URI,reqCols, null, null, null);
if (cursor1.getCount() > 0) {
while (cursor1.moveToNext()){
address = cursor1.getString(cursor1.getColumnIndex(columns[0]));
for (i = 0; i < phno.size(); i++){
if(address.equals(phno.get(i))) {
c++;
break;
}
}
if(c==0)
phno.add(address);
else
c=0;
}
}
cursor1.close();
//Draft
URI = Uri.parse("content://sms/draft");
cursor1 = cr.query(URI,reqCols, null, null, null);
if (cursor1.getCount() > 0) {
while (cursor1.moveToNext()){
address = cursor1.getString(cursor1.getColumnIndex(columns[0]));
for (i = 0; i < phno.size(); i++){
if(address.equals(phno.get(i))) {
c++;
break;
}
}
if(c==0)
phno.add(address);
else
c=0;
}
}
cursor1.close();
//gets contact name
for(i=0;i<phno.size();i++){
nam.add(getContactName(this,phno.get(i)));
}
for(String temp:phno){
URI = Uri.parse("content://sms/inbox");
cursor1 = cr.query(URI, reqCols, null, null, null);
if (cursor1.getCount() > 0) {
while (cursor1.moveToNext()) {
address = cursor1.getString(cursor1.getColumnIndex(columns[0]));
if(address.equals(temp)) {
tempTime.add(cursor1.getString(cursor1.getColumnIndex(columns[2])));// adds date
tempMsg.add(cursor1.getString(cursor1.getColumnIndex(columns[3])));// adds message
tempKind.add(cursor1.getString(cursor1.getColumnIndex(columns[4])));
}
}
}
cursor1.close();
URI = Uri.parse("content://sms/sent");
cursor1 = cr.query(URI, reqCols, null, null, null);
if (cursor1.getCount() > 0) {
while (cursor1.moveToNext()) {
address = cursor1.getString(cursor1.getColumnIndex(columns[0]));
if(address.equals(temp)) {
tempTime.add(cursor1.getString(cursor1.getColumnIndex(columns[2])));// adds date
tempMsg.add(cursor1.getString(cursor1.getColumnIndex(columns[3])));// adds message
tempKind.add(cursor1.getString(cursor1.getColumnIndex(columns[4])));
}
}
}
cursor1.close();
URI = Uri.parse("content://sms/draft");
cursor1 = cr.query(URI, reqCols, null, null, null);
if (cursor1.getCount() > 0) {
while (cursor1.moveToNext()) {
address = cursor1.getString(cursor1.getColumnIndex(columns[0]));
if(address.equals(temp)) {
tempTime.add(cursor1.getString(cursor1.getColumnIndex(columns[2])));// adds date
tempMsg.add(cursor1.getString(cursor1.getColumnIndex(columns[3])));// adds message
tempKind.add(cursor1.getString(cursor1.getColumnIndex(columns[4])));// adds type
}
}
}
cursor1.close();
sort();
lstTime.add(tempTime.get(tempTime.size()-1));
lstMsg.add(tempMsg.get(tempMsg.size()-1));
lstType.add(tempKind.get(tempKind.size()-1));
time.add(convertListToString(tempTime));
message.add(convertListToString(tempMsg));
type.add(convertListToString(tempKind));
}
finalSort();
return START_STICKY;
}
#Override
public void onDestroy() {
super.onDestroy();
}
//finds contact name
public static String getContactName(Context context, String phoneNumber) {
ContentResolver cr = context.getContentResolver();
Uri uri = Uri.withAppendedPath(ContactsContract.PhoneLookup.CONTENT_FILTER_URI, Uri.encode(phoneNumber));
Cursor cursor = cr.query(uri, new String[]{ContactsContract.PhoneLookup.DISPLAY_NAME}, null, null, null);
if (cursor == null) {
return null;
}
String contactName = null;
if(cursor.moveToFirst()) {
contactName = cursor.getString(cursor.getColumnIndex(ContactsContract.PhoneLookup.DISPLAY_NAME));
}
if(cursor != null && !cursor.isClosed()) {
cursor.close();
}
return contactName;
}
// Converts ArrayList to string
public static String convertListToString(List<String> stringList) {
StringBuffer stringBuffer = new StringBuffer();
for (String str : stringList) {
stringBuffer.append(str).append(LIST_SEPARATOR);
}
// Remove last separator
int lastIndex = stringBuffer.lastIndexOf(LIST_SEPARATOR);
stringBuffer.delete(lastIndex, lastIndex + LIST_SEPARATOR.length() + 1);
return stringBuffer.toString();
}
// Converts String to ArrayList
public static List<String> convertStringToList(String str) {
return Arrays.asList(str.split(LIST_SEPARATOR));
}
//Lists Sorting
public void sort(){
for(int j=0;j<tempTime.size();j++){
for(int i=j+1;i<tempTime.size();i++){
if((tempTime.get(i)).compareTo(tempTime.get(j))<0){
String t1 = tempTime.get(j);
String t2 = tempKind.get(j);
String t3 = tempMsg.get(j);
tempTime.set( j, tempTime.get(i));
tempTime.set(i,t1);
tempKind.set( j, tempKind.get(i));
tempKind.set(i,t2);
tempMsg.set( j, tempMsg.get(i));
tempMsg.set(i,t3);
}
}
}
}
//Final
//Lists Sorting
public void finalSort(){
for(int j=0;j<lstTime.size();j++){
for(int i=j+1;i<lstTime.size();i++){
if((lstTime.get(i)).compareTo(lstTime.get(j))<0){
String t1 = lstTime.get(j);
String t2 = lstMsg.get(j);
String t3 = lstType.get(j);
String t4 = time.get(j);
String t5 = message.get(j);
String t6 = type.get(j);
String t7 = phno.get(j);
String t8 = nam.get(j);
lstTime.set( j, lstTime.get(i));
lstTime.set(i,t1);
lstMsg.set( j, lstMsg.get(i));
lstMsg.set(i,t2);
lstType.set( j, lstType.get(i));
lstType.set(i,t3);
time.set( j, time.get(i));
time.set(i,t4);
message.set( j, message.get(i));
message.set(i,t5);
type.set( j, type.get(i));
type.set(i,t6);
phno.set( j, phno.get(i));
phno.set(i,t7);
nam.set( j, nam.get(i));
nam.set(i,t8);
}
}
}
}

Categories